Skip to content

Commit

Permalink
Rename label prop for search field button
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentSmedinga committed May 13, 2024
1 parent df3a973 commit 06f964c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 2 additions & 0 deletions packages/react/src/Pagination/Pagination.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ describe('Pagination', () => {

it('renders custom aria-labels for the ‘previous’ and ‘next’ buttons', () => {
render(<Pagination totalPages={10} previousAriaLabel="Vorige pagina" nextAriaLabel="Volgende pagina" />)

expect(screen.getByText('vorige')).toHaveAttribute('aria-label', 'Vorige pagina')
expect(screen.getByText('volgende')).toHaveAttribute('aria-label', 'Volgende pagina')
})
Expand All @@ -117,6 +118,7 @@ describe('Pagination', () => {
const ref = createRef<HTMLElement>()
const { container } = render(<Pagination totalPages={10} ref={ref} />)
const component = container.querySelector(':only-child')

expect(ref.current).toBe(component)
})
})
2 changes: 1 addition & 1 deletion packages/react/src/SearchField/SearchField.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('Search field', () => {
})

it('renders the button with a label', () => {
render(<SearchField.Button buttonLabel="Search" />)
render(<SearchField.Button label="Search" />)

const component = screen.getByRole('button')

Expand Down
9 changes: 3 additions & 6 deletions packages/react/src/SearchField/SearchFieldButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,15 @@ import { VisuallyHidden } from '../VisuallyHidden'

type SearchFieldButtonProps = {
/** The label for the button that triggers the search action. */
buttonLabel?: string
label?: string
} & HTMLAttributes<HTMLButtonElement>

// TODO: replace this with IconButton when that's done
// TODO: discuss if IconButton is the right component to replace this
export const SearchFieldButton = forwardRef(
(
{ buttonLabel = 'Zoeken', className, ...restProps }: SearchFieldButtonProps,
ref: ForwardedRef<HTMLButtonElement>,
) => (
({ label = 'Zoeken', className, ...restProps }: SearchFieldButtonProps, ref: ForwardedRef<HTMLButtonElement>) => (
<button {...restProps} ref={ref} className={clsx('ams-search-field__button', className)}>
<VisuallyHidden>{buttonLabel}</VisuallyHidden>
<VisuallyHidden>{label}</VisuallyHidden>
<Icon svg={SearchIcon} size="level-5" square />
</button>
),
Expand Down

0 comments on commit 06f964c

Please sign in to comment.