From cbd06599ee4086e2bd8e6b58a6864241ec23f948 Mon Sep 17 00:00:00 2001 From: melloware Date: Wed, 21 Feb 2024 08:38:54 -0500 Subject: [PATCH] Fix #6023: Support NumpadEnter --- components/lib/accordion/Accordion.js | 1 + components/lib/calendar/Calendar.js | 12 ++++-------- components/lib/chip/Chip.js | 2 +- components/lib/contextmenu/ContextMenu.js | 1 + components/lib/datatable/BodyCell.js | 2 +- components/lib/datatable/BodyRow.js | 1 + components/lib/datatable/HeaderCell.js | 2 +- components/lib/dock/Dock.js | 1 + components/lib/dropdown/Dropdown.js | 1 + components/lib/fieldset/Fieldset.js | 2 +- components/lib/fileupload/FileUpload.js | 2 +- components/lib/galleria/GalleriaItem.js | 1 + components/lib/galleria/GalleriaThumbnails.js | 2 +- components/lib/inplace/Inplace.js | 2 +- components/lib/inputnumber/InputNumber.js | 1 + components/lib/megamenu/MegaMenu.js | 2 +- components/lib/menu/Menu.js | 1 + components/lib/menubar/Menubar.js | 3 ++- components/lib/speeddial/SpeedDial.js | 1 + components/lib/splitter/Splitter.js | 1 + components/lib/steps/Steps.js | 1 + components/lib/tabmenu/TabMenu.js | 1 + components/lib/tabview/TabView.js | 1 + components/lib/terminal/Terminal.js | 1 + components/lib/tieredmenu/TieredMenu.js | 1 + components/lib/treetable/TreeTableHeader.js | 2 +- components/lib/tristatecheckbox/TriStateCheckbox.js | 2 +- 27 files changed, 31 insertions(+), 19 deletions(-) diff --git a/components/lib/accordion/Accordion.js b/components/lib/accordion/Accordion.js index 4d96b61a6b..37eb772670 100644 --- a/components/lib/accordion/Accordion.js +++ b/components/lib/accordion/Accordion.js @@ -106,6 +106,7 @@ export const Accordion = React.forwardRef((inProps, ref) => { break; case 'Enter': + case 'NumpadEnter': case 'Space': onTabEnterKey(event, tab, index); break; diff --git a/components/lib/calendar/Calendar.js b/components/lib/calendar/Calendar.js index 12ec5d8a38..eea649d10f 100644 --- a/components/lib/calendar/Calendar.js +++ b/components/lib/calendar/Calendar.js @@ -217,7 +217,7 @@ export const Calendar = React.memo( }; const onPickerKeyDown = (event, type, direction) => { - if (event.code === 'Enter' || event.code === 'Space') { + if (event.key === 'Enter' || event.key === 'Space') { onTimePickerElementMouseDown(event, type, direction); event.preventDefault(); @@ -228,7 +228,7 @@ export const Calendar = React.memo( }; const onPickerKeyUp = (event) => { - if (event.code === 'Enter' || event.code === 'Space') { + if (event.key === 'Enter' || event.key === 'Space') { onTimePickerElementMouseUp(); event.preventDefault(); @@ -1229,7 +1229,6 @@ export const Calendar = React.memo( case 'Enter': case 'NumpadEnter': - case 'Space': { onDateSelect(event, date); event.preventDefault(); @@ -1340,7 +1339,6 @@ export const Calendar = React.memo( switch (event.code) { //arrows case 'ArrowUp': - case 'ArrowDown': { cell.tabIndex = '-1'; const cells = cell.parentElement.children; @@ -1408,7 +1406,6 @@ export const Calendar = React.memo( case 'Enter': case 'NumpadEnter': - case 'Space': { if (props.view !== 'month') viewChangedWithKeyDown.current = true; @@ -1440,7 +1437,6 @@ export const Calendar = React.memo( switch (event.code) { //arrows case 'ArrowUp': - case 'ArrowDown': { cell.tabIndex = '-1'; var cells = cell.parentElement.children; @@ -1669,7 +1665,7 @@ export const Calendar = React.memo( }; const switchToMonthView = (event) => { - if (event && event.code && (event.code === 'Enter' || event.code === 'Space')) { + if (event && event.code && (event.code === 'Enter' || event.code === 'NumpadEnter' || event.code === 'Space')) { viewChangedWithKeyDown.current = true; } @@ -1678,7 +1674,7 @@ export const Calendar = React.memo( }; const switchToYearView = (event) => { - if (event && event.code && (event.code === 'Enter' || event.code === 'Space')) { + if (event && event.code && (event.code === 'Enter' || event.code === 'NumpadEnter' || event.code === 'Space')) { viewChangedWithKeyDown.current = true; } diff --git a/components/lib/chip/Chip.js b/components/lib/chip/Chip.js index 0e3b9af89f..5e7085fdad 100644 --- a/components/lib/chip/Chip.js +++ b/components/lib/chip/Chip.js @@ -20,7 +20,7 @@ export const Chip = React.memo( useHandleStyle(ChipBase.css.styles, isUnstyled, { name: 'chip' }); const onKeyDown = (event) => { - if (event.code === 'Enter' || event.code === 'Backspace') { + if (event.code === 'Enter' || event.code === 'NumpadEnter' || event.code === 'Backspace') { close(event); } }; diff --git a/components/lib/contextmenu/ContextMenu.js b/components/lib/contextmenu/ContextMenu.js index 892f28239c..14f6eca0f8 100644 --- a/components/lib/contextmenu/ContextMenu.js +++ b/components/lib/contextmenu/ContextMenu.js @@ -384,6 +384,7 @@ export const ContextMenu = React.memo( break; case 'Enter': + case 'NumpadEnter': onEnterKey(event); break; diff --git a/components/lib/datatable/BodyCell.js b/components/lib/datatable/BodyCell.js index 2d93b3f831..fa7769f8c5 100644 --- a/components/lib/datatable/BodyCell.js +++ b/components/lib/datatable/BodyCell.js @@ -362,7 +362,7 @@ export const BodyCell = React.memo((props) => { const onKeyDown = (event) => { if (props.editMode !== 'row') { - if (event.code === 'Enter' || event.code === 'Tab') { + if (event.code === 'Enter' || event.code === 'NumpadEnter' || event.code === 'Tab') { switchCellToViewMode(event, true); } diff --git a/components/lib/datatable/BodyRow.js b/components/lib/datatable/BodyRow.js index 670b92af21..294c1e567d 100644 --- a/components/lib/datatable/BodyRow.js +++ b/components/lib/datatable/BodyRow.js @@ -179,6 +179,7 @@ export const BodyRow = React.memo((props) => { break; case 'Enter': + case 'NumpadEnter': onEnterKey(row, event, target); break; diff --git a/components/lib/datatable/HeaderCell.js b/components/lib/datatable/HeaderCell.js index b85ff3376a..ba09f28238 100644 --- a/components/lib/datatable/HeaderCell.js +++ b/components/lib/datatable/HeaderCell.js @@ -169,7 +169,7 @@ export const HeaderCell = React.memo((props) => { }; const onKeyDown = (event) => { - if ((event.code == 'Enter' || event.code == 'Space') && event.currentTarget === elementRef.current && DomHandler.getAttribute(event.currentTarget, 'data-p-sortable-column') === 'true') { + if ((event.code == 'Enter' || event.code === 'NumpadEnter' || event.code == 'Space') && event.currentTarget === elementRef.current && DomHandler.getAttribute(event.currentTarget, 'data-p-sortable-column') === 'true') { onClick(event); event.preventDefault(); diff --git a/components/lib/dock/Dock.js b/components/lib/dock/Dock.js index 9abf680f42..f3579a35a6 100644 --- a/components/lib/dock/Dock.js +++ b/components/lib/dock/Dock.js @@ -97,6 +97,7 @@ export const Dock = React.memo( break; case 'Enter': + case 'NumpadEnter': case 'Space': onSpaceKey(event); event.preventDefault(); diff --git a/components/lib/dropdown/Dropdown.js b/components/lib/dropdown/Dropdown.js index eef24d2738..ac4dea929c 100644 --- a/components/lib/dropdown/Dropdown.js +++ b/components/lib/dropdown/Dropdown.js @@ -267,6 +267,7 @@ export const Dropdown = React.memo( case 'Escape': case 'Enter': + case 'NumpadEnter': onEnterKey(event); event.preventDefault(); break; diff --git a/components/lib/fieldset/Fieldset.js b/components/lib/fieldset/Fieldset.js index 1215b8fac1..e0a1ba0524 100644 --- a/components/lib/fieldset/Fieldset.js +++ b/components/lib/fieldset/Fieldset.js @@ -69,7 +69,7 @@ export const Fieldset = React.forwardRef((inProps, ref) => { }); const onKeyDown = (event) => { - if (event.code === 'Enter' || event.code === 'Space') { + if (event.code === 'Enter' || event.code === 'NumpadEnter' || event.code === 'Space') { toggle(event); event.preventDefault(); } diff --git a/components/lib/fileupload/FileUpload.js b/components/lib/fileupload/FileUpload.js index 646c6bc838..8f3c714772 100644 --- a/components/lib/fileupload/FileUpload.js +++ b/components/lib/fileupload/FileUpload.js @@ -292,7 +292,7 @@ export const FileUpload = React.memo( }; const onKeyDown = (event) => { - if (event.code === 'Enter') { + if (event.code === 'Enter' || event.code === 'NumpadEnter') { choose(); } }; diff --git a/components/lib/galleria/GalleriaItem.js b/components/lib/galleria/GalleriaItem.js index fae40c0b93..5c8106c5a5 100644 --- a/components/lib/galleria/GalleriaItem.js +++ b/components/lib/galleria/GalleriaItem.js @@ -88,6 +88,7 @@ export const GalleriaItem = React.memo( const onIndicatorKeyDown = (event, index) => { switch (event.code) { case 'Enter': + case 'NumpadEnter': case 'Space': stopSlideShow(); diff --git a/components/lib/galleria/GalleriaThumbnails.js b/components/lib/galleria/GalleriaThumbnails.js index ce857f9c3f..5f125742d1 100644 --- a/components/lib/galleria/GalleriaThumbnails.js +++ b/components/lib/galleria/GalleriaThumbnails.js @@ -31,7 +31,7 @@ const GalleriaThumbnailItem = React.memo((props) => { }; const onThumbnailKeydown = (event) => { - if (event.code === 'Enter' || event.code === 'Space') { + if (event.code === 'Enter' || event.code === 'NumpadEnter' || event.code === 'Space') { props.onItemClick({ originalEvent: event, index: props.index diff --git a/components/lib/inplace/Inplace.js b/components/lib/inplace/Inplace.js index 9bc041b290..16243eff43 100644 --- a/components/lib/inplace/Inplace.js +++ b/components/lib/inplace/Inplace.js @@ -63,7 +63,7 @@ export const Inplace = React.forwardRef((inProps, ref) => { }; const onDisplayKeyDown = (event) => { - if (event.code === 'Enter' || event.code === 'Space') { + if (event.code === 'Enter' || event.code === 'NumpadEnter' || event.code === 'Space') { open(event); event.preventDefault(); } diff --git a/components/lib/inputnumber/InputNumber.js b/components/lib/inputnumber/InputNumber.js index 3bd88f7796..e525e5c32d 100644 --- a/components/lib/inputnumber/InputNumber.js +++ b/components/lib/inputnumber/InputNumber.js @@ -380,6 +380,7 @@ export const InputNumber = React.memo( //enter and tab case 'Tab': case 'Enter': + case 'NumpadEnter': newValueStr = validateValue(parseValue(inputValue)); inputRef.current.value = formatValue(newValueStr); inputRef.current.setAttribute('aria-valuenow', newValueStr); diff --git a/components/lib/megamenu/MegaMenu.js b/components/lib/megamenu/MegaMenu.js index fa823eee67..73f60591b7 100644 --- a/components/lib/megamenu/MegaMenu.js +++ b/components/lib/megamenu/MegaMenu.js @@ -391,6 +391,7 @@ export const MegaMenu = React.memo( break; case 'Enter': + case 'NumpadEnter': onEnterKey(event); break; @@ -406,7 +407,6 @@ export const MegaMenu = React.memo( case 'PageUp': case 'Backspace': case 'ShiftLeft': - focusedItemInfo; case 'ShiftRight': //NOOP break; diff --git a/components/lib/menu/Menu.js b/components/lib/menu/Menu.js index 0f7b948491..5e412859d6 100644 --- a/components/lib/menu/Menu.js +++ b/components/lib/menu/Menu.js @@ -131,6 +131,7 @@ export const Menu = React.memo( break; case 'Enter': + case 'NumpadEnter': onEnterKey(event); break; diff --git a/components/lib/menubar/Menubar.js b/components/lib/menubar/Menubar.js index 847fd9d2f2..c41a4ac48a 100644 --- a/components/lib/menubar/Menubar.js +++ b/components/lib/menubar/Menubar.js @@ -96,7 +96,7 @@ export const Menubar = React.memo( }; const menuButtonKeydown = (event) => { - (event.code === 'Enter' || event.code === 'Space') && toggle(event); + (event.code === 'Enter' || event.code === 'NumpadEnter' || event.code === 'Space') && toggle(event); }; const isOutsideClicked = (event) => { @@ -167,6 +167,7 @@ export const Menubar = React.memo( break; case 'Enter': + case 'NumpadEnter': onEnterKey(event); break; diff --git a/components/lib/speeddial/SpeedDial.js b/components/lib/speeddial/SpeedDial.js index bbf543ade4..f692bdb36f 100644 --- a/components/lib/speeddial/SpeedDial.js +++ b/components/lib/speeddial/SpeedDial.js @@ -106,6 +106,7 @@ export const SpeedDial = React.memo( break; case 'Enter': + case 'NumpadEnter': case 'Space': onEnterKey(event); break; diff --git a/components/lib/splitter/Splitter.js b/components/lib/splitter/Splitter.js index 1a8e091aa3..a6eb43f5cb 100644 --- a/components/lib/splitter/Splitter.js +++ b/components/lib/splitter/Splitter.js @@ -266,6 +266,7 @@ export const Splitter = React.memo( break; } + case 'NumpadEnter': case 'Enter': { if (prevSize.current > 100 - (minSize || 5)) { resizePanel(index, minSize, 100); diff --git a/components/lib/steps/Steps.js b/components/lib/steps/Steps.js index f5dc862a1f..d9c64d538b 100644 --- a/components/lib/steps/Steps.js +++ b/components/lib/steps/Steps.js @@ -84,6 +84,7 @@ export const Steps = React.memo( break; case 'Enter': + case 'NumpadEnter': case 'Space': itemClick(event, item, index); event.preventDefault(); diff --git a/components/lib/tabmenu/TabMenu.js b/components/lib/tabmenu/TabMenu.js index f159114f75..541dfbf3d0 100644 --- a/components/lib/tabmenu/TabMenu.js +++ b/components/lib/tabmenu/TabMenu.js @@ -138,6 +138,7 @@ export const TabMenu = React.memo( case 'Space': case 'Enter': + case 'NumpadEnter': itemClick(event, item, index); event.preventDefault(); break; diff --git a/components/lib/tabview/TabView.js b/components/lib/tabview/TabView.js index c491279982..63743a9cd3 100644 --- a/components/lib/tabview/TabView.js +++ b/components/lib/tabview/TabView.js @@ -149,6 +149,7 @@ export const TabView = React.forwardRef((inProps, ref) => { break; case 'Enter': + case 'NumpadEnter': case 'Space': onTabEnterKey(event, tab, index); break; diff --git a/components/lib/terminal/Terminal.js b/components/lib/terminal/Terminal.js index 29cb420a79..acaa97fb76 100644 --- a/components/lib/terminal/Terminal.js +++ b/components/lib/terminal/Terminal.js @@ -58,6 +58,7 @@ export const Terminal = React.memo( break; case 'Enter': + case 'NumpadEnter': if (!!commandTextState) { let newCommands = [...commandsState]; diff --git a/components/lib/tieredmenu/TieredMenu.js b/components/lib/tieredmenu/TieredMenu.js index ffd1070bbc..9d037dffcf 100644 --- a/components/lib/tieredmenu/TieredMenu.js +++ b/components/lib/tieredmenu/TieredMenu.js @@ -153,6 +153,7 @@ export const TieredMenu = React.memo( break; case 'Enter': + case 'NumpadEnter': onEnterKey(event); break; diff --git a/components/lib/treetable/TreeTableHeader.js b/components/lib/treetable/TreeTableHeader.js index 382d050877..5d2bed3498 100644 --- a/components/lib/treetable/TreeTableHeader.js +++ b/components/lib/treetable/TreeTableHeader.js @@ -64,7 +64,7 @@ export const TreeTableHeader = React.memo((props) => { }; const onHeaderKeyDown = (event, column) => { - if (event.key === 'Enter' && event.key === 'Space') { + if (event.key === 'Enter' || event.code === 'Space') { onHeaderClick(event, column); event.preventDefault(); } diff --git a/components/lib/tristatecheckbox/TriStateCheckbox.js b/components/lib/tristatecheckbox/TriStateCheckbox.js index b4abbdb6d4..67c350888b 100644 --- a/components/lib/tristatecheckbox/TriStateCheckbox.js +++ b/components/lib/tristatecheckbox/TriStateCheckbox.js @@ -67,7 +67,7 @@ export const TriStateCheckbox = React.memo( }; const onKeyDown = (e) => { - if (e.code === 'Enter' || e.code === 'Space') { + if (e.code === 'Enter' || e.code === 'NumpadEnter' || e.code === 'Space') { toggle(e); e.preventDefault(); }