Skip to content

Commit

Permalink
fix(a11y/NativeSelect): hide duplication of selected option from scre…
Browse files Browse the repository at this point in the history
…en reader (#5132)

* bug(NativeSelect) Remove duplication of selected option

Hide it from screen reader
We can't just remove it as it's needed to visually show
the select according to the design.

* Add a11y basic test
  • Loading branch information
mendrew authored May 29, 2023
1 parent 7712fea commit bb1a793
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions packages/vkui/src/components/NativeSelect/NativeSelect.test.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import React, { useState } from 'react';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { a11yBasicTest } from '../../testing/a11y';
import { baselineComponent } from '../../testing/utils';
import { NativeSelect } from './NativeSelect';

describe('NativeSelect', () => {
baselineComponent(NativeSelect);
a11yBasicTest(() => (
<>
<label htmlFor="name">Name:</label>
<NativeSelect id="name" data-testid="target" value="0">
<option value="0">Mike</option>
<option value="1">Josh</option>
</NativeSelect>
</>
));

it('works correctly with value and onChange', () => {
const SelectController = () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/vkui/src/components/NativeSelect/NativeSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const NativeSelect = ({
{placeholder && <option value="">{placeholder}</option>}
{children}
</select>
<div className={styles['Select__container']}>
<div className={styles['Select__container']} aria-hidden>
<SelectTypography className={styles['Select__title']} selectType={selectType}>
{title}
</SelectTypography>
Expand Down

0 comments on commit bb1a793

Please sign in to comment.