diff --git a/app/javascript/packages/document-capture/components/file-input.jsx b/app/javascript/packages/document-capture/components/file-input.jsx index 346b5bd100e..c353ac1d4d7 100644 --- a/app/javascript/packages/document-capture/components/file-input.jsx +++ b/app/javascript/packages/document-capture/components/file-input.jsx @@ -159,6 +159,7 @@ function FileInput(props, ref) { const inputId = `file-input-${instanceId}`; const hintId = `${inputId}-hint`; const innerHintId = `${hintId}-inner`; + const labelId = `${inputId}-label`; /** * In response to a file input change event, confirms that the file is valid before calling @@ -194,17 +195,29 @@ function FileInput(props, ref) { } /** - * @param {string} fileLabel String velue of the label for input to display + * @param {string} fileLabel String value of the label for input to display * @param {Blob|string|null|undefined} fileValue File or string for which to generate label. + * @return {{'aria-label': string} | {'aria-labelledby': string}} */ - function getLabelFromValue(fileLabel, fileValue) { + function getAriaLabelPropsFromValue(fileLabel, fileValue) { if (fileValue instanceof window.File) { - return `${fileLabel} - ${fileValue.name}`; + return { + 'aria-label': `${fileLabel} - ${fileValue.name}`, + }; } + if (fileValue) { - return `${fileLabel} - ${t('doc_auth.forms.captured_image')}`; + return { + 'aria-label': `${fileLabel} - ${t('doc_auth.forms.captured_image')}`, + }; } - return ''; + + // When no file is selected, provide a slightly more verbose label + // including the actual