From d6916b531d25a693c1e0773d4b6b6e96b0b1148f Mon Sep 17 00:00:00 2001 From: emyarod Date: Tue, 17 Mar 2020 20:03:28 -0500 Subject: [PATCH] fix(TableToolbarSearch): set focus on expanded search bar (#5637) --- packages/react/src/components/DataTable/TableToolbarSearch.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/react/src/components/DataTable/TableToolbarSearch.js b/packages/react/src/components/DataTable/TableToolbarSearch.js index bf2c81b742ec..c00a41593825 100644 --- a/packages/react/src/components/DataTable/TableToolbarSearch.js +++ b/packages/react/src/components/DataTable/TableToolbarSearch.js @@ -80,6 +80,9 @@ const TableToolbarSearch = ({ const handleExpand = (event, value = !expanded) => { if (!controlled && (!persistent || (!persistent && !persistant))) { setExpandedState(value); + if (value) { + setFocusTarget(searchRef); + } } if (onExpand) { onExpand(event, value); @@ -87,7 +90,6 @@ const TableToolbarSearch = ({ }; const onClick = e => { - setFocusTarget(searchRef); handleExpand(e, true); };