Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EuiSelectableTemplateSitewide] fix: The keydown popup display shall be Enter key. #5886

Merged
merged 7 commits into from
May 17, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
isWithinBreakpoints,
} from '../../../services/breakpoint';
import { EuiSpacer } from '../../spacer';
import { ENTER } from '../../../services/keys';

export type EuiSelectableTemplateSitewideProps = Partial<
Omit<EuiSelectableProps<{ [key: string]: any }>, 'options'>
Expand Down Expand Up @@ -142,21 +143,24 @@ export const EuiSelectableTemplateSitewide: FunctionComponent<EuiSelectableTempl
* Search helpers
*/
const searchOnFocus = (e: React.FocusEvent<HTMLInputElement>) => {
searchProps && searchProps.onFocus && searchProps.onFocus(e);
if (canShowPopoverButton) return;

searchProps?.onFocus?.(e);
setPopoverIsOpen(true);
};

const onSearchInput = (e: React.FormEvent<HTMLInputElement>) => {
searchProps && searchProps.onInput && searchProps.onInput(e);
searchProps?.onInput?.(e);
setPopoverIsOpen(true);
};

const searchOnBlur = (e: React.FocusEvent<HTMLInputElement>) => {
searchProps && searchProps.onBlur && searchProps.onBlur(e);
if (canShowPopoverButton) return;
const onSearchKeydown = (e: React.KeyboardEvent<HTMLInputElement>) => {
searchProps?.onKeyDown?.(e);
if (e.key === ENTER) {
setPopoverIsOpen(true);
}
};

const searchOnBlur = (e: React.FocusEvent<HTMLInputElement>) => {
searchProps?.onBlur?.(e);
if (!popoverRef?.contains(e.relatedTarget as HTMLElement)) {
setPopoverIsOpen(false);
}
Expand Down Expand Up @@ -235,6 +239,7 @@ export const EuiSelectableTemplateSitewide: FunctionComponent<EuiSelectableTempl
onFocus: searchOnFocus,
onBlur: searchOnBlur,
onInput: onSearchInput,
onKeyDown: onSearchKeydown,
className: searchClasses,
}}
listProps={{
Expand Down
3 changes: 3 additions & 0 deletions upcoming_changelogs/5886.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**Bug fixes**

- Fixed `EuiSelectableTemplateSitewide` to allow re-opening the search popover (if closed via Escape key) via the Enter key