From 074f1565b75d3fe28254822db804c46ffa44d953 Mon Sep 17 00:00:00 2001 From: Federico Ercoles Date: Thu, 25 Jan 2024 17:21:11 +0100 Subject: [PATCH] Allow control of Select open-on-focus behavior --- packages/bento-design-system/src/SelectField/BaseSelect.tsx | 2 +- packages/bento-design-system/src/SelectField/Config.ts | 1 + packages/bento-design-system/src/SelectField/types.ts | 1 + packages/bento-design-system/src/util/defaultConfigs.tsx | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/bento-design-system/src/SelectField/BaseSelect.tsx b/packages/bento-design-system/src/SelectField/BaseSelect.tsx index 2c6b4f364..4755fce1d 100644 --- a/packages/bento-design-system/src/SelectField/BaseSelect.tsx +++ b/packages/bento-design-system/src/SelectField/BaseSelect.tsx @@ -107,7 +107,7 @@ export function BaseSelect(props: Props) { placeholder={placeholder} menuPortalTarget={menuPortalTarget.current} components={selectComponents} - openMenuOnFocus + openMenuOnFocus={props.openMenuOnFocus ?? dropdownConfig.openMenuOnFocus} styles={selectComponents.styles>()} validationState={validationState} isMulti={isMulti} diff --git a/packages/bento-design-system/src/SelectField/Config.ts b/packages/bento-design-system/src/SelectField/Config.ts index b28c85277..7e64edb31 100644 --- a/packages/bento-design-system/src/SelectField/Config.ts +++ b/packages/bento-design-system/src/SelectField/Config.ts @@ -16,4 +16,5 @@ export type DropdownConfig = { openIndicatorIconSize: IconProps["size"]; chipColor: ChipProps["color"]; chipSpacing: BentoSprinkles["gap"]; + openMenuOnFocus: boolean; }; diff --git a/packages/bento-design-system/src/SelectField/types.ts b/packages/bento-design-system/src/SelectField/types.ts index d6b416d1a..3ba619145 100644 --- a/packages/bento-design-system/src/SelectField/types.ts +++ b/packages/bento-design-system/src/SelectField/types.ts @@ -38,4 +38,5 @@ export type BaseSelectProps = { noOptionsMessage?: LocalizedString; isReadOnly?: boolean; searchable?: boolean; + openMenuOnFocus?: boolean; }; diff --git a/packages/bento-design-system/src/util/defaultConfigs.tsx b/packages/bento-design-system/src/util/defaultConfigs.tsx index 603ecdd26..9a121cc43 100644 --- a/packages/bento-design-system/src/util/defaultConfigs.tsx +++ b/packages/bento-design-system/src/util/defaultConfigs.tsx @@ -499,6 +499,7 @@ export const dropdown: DropdownConfig = { openIndicatorIconSize: 24, chipColor: "indigo", chipSpacing: 4, + openMenuOnFocus: true, }; export const table: TableConfig = {