Skip to content

Commit

Permalink
Refactor: Prevent File Upload description from triggering file select…
Browse files Browse the repository at this point in the history
…ion modal (#7433)
  • Loading branch information
pauloiankoski authored and kjohnson committed Aug 21, 2024
1 parent 965203a commit 0291ac8
Showing 1 changed file with 7 additions and 11 deletions.
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>
</>
);
}

0 comments on commit 0291ac8

Please sign in to comment.