Skip to content

Commit

Permalink
fix: primefaces primefaces#6269, Dropdown: (accessiblility) cannot ac…
Browse files Browse the repository at this point in the history
…cess and clear the selected input using using keyboard
  • Loading branch information
akshayantony55 committed Mar 31, 2024
1 parent 411f26a commit 21f4ea3
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions components/lib/dropdown/Dropdown.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import PrimeReact, { FilterService, PrimeReactContext } from '../api/Api';
import PrimeReact, { FilterService, PrimeReactContext, localeOption } from '../api/Api';
import { useHandleStyle } from '../componentbase/ComponentBase';
import { useMergeProps, useMountEffect, useOverlayListener, useUnmountEffect, useUpdateEffect } from '../hooks/Hooks';
import { ChevronDownIcon } from '../icons/chevrondown';
Expand Down Expand Up @@ -1099,12 +1099,22 @@ export const Dropdown = React.memo(
return <span {...inputProps}>{content}</span>;
};

const onClearIconKeyDown = (event) => {
if (event.key === 'Enter' || event.code === 'Space') {
clear(event);
event.preventDefault();
}
};

const createClearIcon = () => {
if (props.value != null && props.showClear && !props.disabled) {
const clearIconProps = mergeProps(
{
className: cx('clearIcon'),
onPointerUp: clear
onPointerUp: clear,
tabIndex: props.tabIndex || '0',
onKeyDown: onClearIconKeyDown,
'aria-label': localeOption('clear')
},
ptm('clearIcon')
);
Expand Down

0 comments on commit 21f4ea3

Please sign in to comment.