From cbdecd8e23ef37c9f679ea93c4e69121399d36e3 Mon Sep 17 00:00:00 2001 From: Matt Gallo Date: Wed, 26 Apr 2023 09:42:44 -0400 Subject: [PATCH] feat(Datagrid): add keyboard support for clickable rows (#2914) * feat(Datagrid): add keyboard support to useOnRowClick * chore(Datagrid): refactor key down fn name --------- Co-authored-by: Alexander Melo --- .../src/components/Datagrid/useOnRowClick.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/cloud-cognitive/src/components/Datagrid/useOnRowClick.js b/packages/cloud-cognitive/src/components/Datagrid/useOnRowClick.js index 083638d165..f564db62d1 100644 --- a/packages/cloud-cognitive/src/components/Datagrid/useOnRowClick.js +++ b/packages/cloud-cognitive/src/components/Datagrid/useOnRowClick.js @@ -23,10 +23,18 @@ const useOnRowClick = (hooks) => { } }; + const onKeyDown = (event) => { + const { key } = event; + if (key === 'Enter') { + onClick(); + } + }; + return [ props, - { onClick }, + { onClick, onKeyDown }, { + tabIndex: 0, style: { cursor: 'pointer', },