Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Prevent File Upload description from triggering file selection modal #7433

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions src/DonationForms/resources/registrars/templates/fields/File.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
import {FileProps} from '@givewp/forms/propTypes';

export default function File({
Label,
allowedMimeTypes,
ErrorMessage,
fieldError,
description,
inputProps,
}: FileProps) {
export default function File({Label, allowedMimeTypes, ErrorMessage, fieldError, description, inputProps}: FileProps) {
const FieldDescription = window.givewp.form.templates.layouts.fieldDescription;
const {setValue} = window.givewp.form.hooks.useFormContext();
const {name} = inputProps;

return (
<label>
<Label />
<>
<label htmlFor={`${name}-field`}>
<Label />
</label>
{description && <FieldDescription description={description} />}

<input
id={`${name}-field`}
type="file"
aria-invalid={fieldError ? 'true' : 'false'}
accept={allowedMimeTypes.join(',')}
Expand All @@ -29,6 +25,6 @@ export default function File({
<input type="hidden" {...inputProps} />

<ErrorMessage />
</label>
</>
);
}
Loading