From 3c703d371802d594bd8d18a0eaeb48704336ae00 Mon Sep 17 00:00:00 2001 From: Paul Sealock Date: Fri, 17 Nov 2023 10:07:01 +1300 Subject: [PATCH] Tree Select Control: Use enter button for selection (#41480) * enable enter to select * Add changefile(s) from automation for the following project(s): @woocommerce/components --------- Co-authored-by: github-actions --- .../41480-update-tree-select-control-enter-btn-trunk | 4 ++++ packages/js/components/src/tree-select-control/index.js | 5 +++++ 2 files changed, 9 insertions(+) create mode 100644 packages/js/components/changelog/41480-update-tree-select-control-enter-btn-trunk diff --git a/packages/js/components/changelog/41480-update-tree-select-control-enter-btn-trunk b/packages/js/components/changelog/41480-update-tree-select-control-enter-btn-trunk new file mode 100644 index 00000000000..f98e92fedd4 --- /dev/null +++ b/packages/js/components/changelog/41480-update-tree-select-control-enter-btn-trunk @@ -0,0 +1,4 @@ +Significance: minor +Type: update + +Improve keyboard interaction of Tree Select Control component. \ No newline at end of file diff --git a/packages/js/components/src/tree-select-control/index.js b/packages/js/components/src/tree-select-control/index.js index fc1a3a9167b..21b3cab6c4b 100644 --- a/packages/js/components/src/tree-select-control/index.js +++ b/packages/js/components/src/tree-select-control/index.js @@ -331,6 +331,11 @@ const TreeSelectControl = ( { if ( ENTER === event.key ) { setTreeVisible( true ); + + if ( event.target.type === 'checkbox' ) { + event.target.click(); + } + event.preventDefault(); }