Skip to content

Commit 4b11454

Browse files
committed
fix(select): prevent modal form closing immediately when opened with Enter
1 parent ce86063 commit 4b11454

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

core/src/components/select-modal/select-modal.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,20 @@ export class SelectModal implements ComponentInterface {
9494
justify="start"
9595
labelPlacement="end"
9696
onClick={() => this.closeModal()}
97+
onKeyDown={(ev) => {
98+
if (ev.key === 'Enter') {
99+
/**
100+
* Selecting a radio option with keyboard navigation,
101+
* Enter key should dismiss the modal.
102+
*/
103+
this.closeModal();
104+
}
105+
}}
97106
onKeyUp={(ev) => {
98-
if (ev.key === 'Enter' || ev.key === ' ') {
107+
if (ev.key === ' ') {
99108
/**
100109
* Selecting a radio option with keyboard navigation,
101-
* either through the Enter or Space keys, should
102-
* dismiss the modal.
110+
* Space key should dismiss the modal.
103111
*/
104112
this.closeModal();
105113
}

core/src/components/select-popover/select-popover.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,20 @@ export class SelectPopover implements ComponentInterface {
159159
value={option.value}
160160
disabled={option.disabled}
161161
onClick={() => this.dismissParentPopover()}
162+
onKeyDown={(ev) => {
163+
if (ev.key === 'Enter') {
164+
/**
165+
* Selecting a radio option with keyboard navigation,
166+
* Enter key should dismiss the popover.
167+
*/
168+
this.dismissParentPopover();
169+
}
170+
}}
162171
onKeyUp={(ev) => {
163-
if (ev.key === 'Enter' || ev.key === ' ') {
172+
if (ev.key === ' ') {
164173
/**
165174
* Selecting a radio option with keyboard navigation,
166-
* either through the Enter or Space keys, should
167-
* dismiss the popover.
175+
* Space key should dismiss the popover.
168176
*/
169177
this.dismissParentPopover();
170178
}

0 commit comments

Comments
 (0)