From 676c3e2229d549334f5e95a1cc2ec3eb5f970fb9 Mon Sep 17 00:00:00 2001 From: Anurag Hazra Date: Tue, 25 Aug 2020 13:16:04 +0530 Subject: [PATCH] fix(select): reduce typeahead delay & focus selection bug (#8) * fix: select component delay & focus selection bug * chore: storybook addon config --- .storybook/manager.js | 14 ++++++++++++++ src/select/SelectDropdown.ts | 8 +++++--- 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 .storybook/manager.js diff --git a/.storybook/manager.js b/.storybook/manager.js new file mode 100644 index 000000000..f0c4af418 --- /dev/null +++ b/.storybook/manager.js @@ -0,0 +1,14 @@ +import { addons } from "@storybook/addons"; + +addons.setConfig({ + isFullscreen: false, + showNav: true, + showPanel: true, + panelPosition: "bottom", + sidebarAnimations: true, + enableShortcuts: false, + isToolshown: true, + theme: undefined, + initialActive: "sidebar", + showRoots: false, +}); diff --git a/src/select/SelectDropdown.ts b/src/select/SelectDropdown.ts index 58db6862a..ba82ed69e 100644 --- a/src/select/SelectDropdown.ts +++ b/src/select/SelectDropdown.ts @@ -80,12 +80,14 @@ const useSelectDropdown = createHook({ dataAttrValue.startsWith(typehead) ) { setCurrentId(item.id); - // remain dropdown open on setSelected - setSelected(dataAttrValue, true); move(item.id); + if (!visible) { + // remain dropdown open on setSelected + setSelected(dataAttrValue, true); + } } }); - }, 400), + }, 150), [typehead], );