Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## [`master`](https://github.com/elastic/eui/tree/master)

- Added default prompt text to `aria-describedby` for `EuiFilePicker` ([#2919](https://github.com/elastic/eui/pull/2919))
- Added SASS variables for text variants of the primary palette `$euiColorPrimaryText`, `$euiColorSecondaryText`, etc... Updated components to use these new variables. ([#2873](https://github.com/elastic/eui/pull/2873))
- Updated SASS mixin `makeHighContrastColor()` to default `$background: $euiPageBackgroundColor` and `$ratio: 4.5`. Created `makeGraphicContrastColor()` for graphic specific contrast levels of 3.0. ([#2873](https://github.com/elastic/eui/pull/2873))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ exports[`EuiFilePicker is rendered 1`] = `
class="euiFilePicker__wrap"
>
<input
aria-describedby="htmlId"
aria-label="aria-label"
class="euiFilePicker__input"
data-test-subj="test subject string"
type="file"
/>
<div
class="euiFilePicker__prompt"
id="htmlId"
>
<div
aria-hidden="true"
Expand Down
5 changes: 5 additions & 0 deletions src/components/form/file_picker/file_picker.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import { requiredProps } from '../../../test';

import { EuiFilePicker } from './file_picker';

// Mock the htmlIdGenerator to generate predictable ids for snapshot tests
jest.mock('../../../services/accessibility/html_id_generator', () => ({
htmlIdGenerator: () => () => 'htmlId',
}));

describe('EuiFilePicker', () => {
test('is rendered', () => {
const component = render(<EuiFilePicker {...requiredProps} />);
Expand Down
10 changes: 9 additions & 1 deletion src/components/form/file_picker/file_picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { EuiProgress } from '../../progress';
import { EuiIcon } from '../../icon';
import { EuiI18n } from '../../i18n';
import { EuiLoadingSpinner } from '../../loading';
import { htmlIdGenerator } from '../../../services/accessibility/html_id_generator';

const displayToClassNameMap = {
default: null,
Expand Down Expand Up @@ -127,6 +128,12 @@ export class EuiFilePicker extends Component<EuiFilePickerProps> {
...rest
} = this.props;

let promptId: string = htmlIdGenerator()();

if (id) {
promptId = `${id}-filePicker__prompt`;
}

const isOverridingInitialPrompt = this.state.promptText != null;

const normalFormControl = display === 'default';
Expand Down Expand Up @@ -198,10 +205,11 @@ export class EuiFilePicker extends Component<EuiFilePickerProps> {
onDragLeave={this.hideDrop}
onDrop={this.hideDrop}
disabled={disabled}
aria-describedby={promptId}
{...rest}
/>
</EuiValidatableControl>
<div className="euiFilePicker__prompt">
<div className="euiFilePicker__prompt" id={promptId}>
<EuiIcon
className="euiFilePicker__icon"
type="importAction"
Expand Down