From d68565b43c56976aae9288fed466e170095c2f27 Mon Sep 17 00:00:00 2001 From: devanshu052000 Date: Mon, 17 Mar 2025 17:15:36 +0530 Subject: [PATCH 1/3] Added support for arrow key navigation in Dropdown and Multiselect component. --- .../Components/DropdownV2/DropdownV2.jsx | 28 ++++++++++++++++--- .../MultiselectV2/CustomValueContainer.jsx | 9 +++++- .../MultiselectV2/MultiselectV2.jsx | 20 ++++++++++++- 3 files changed, 51 insertions(+), 6 deletions(-) diff --git a/frontend/src/Editor/Components/DropdownV2/DropdownV2.jsx b/frontend/src/Editor/Components/DropdownV2/DropdownV2.jsx index a01ed895e0..b2445435c0 100644 --- a/frontend/src/Editor/Components/DropdownV2/DropdownV2.jsx +++ b/frontend/src/Editor/Components/DropdownV2/DropdownV2.jsx @@ -88,6 +88,7 @@ export const DropdownV2 = ({ padding, } = styles; const isInitialRender = useRef(true); + const [isMenuOpen, setIsMenuOpen] = useState(false); const [currentValue, setCurrentValue] = useState(() => findDefaultItem(schema)); const isMandatory = validation?.mandatory ?? false; const options = properties?.options; @@ -353,15 +354,16 @@ export const DropdownV2 = ({ ...provided, padding: '0px', }), - option: (provided) => ({ + option: (provided, _state) => ({ ...provided, - backgroundColor: 'var(--surfaces-surface-01)', + backgroundColor: _state.isFocused ? 'var(--interactive-overlays-fill-hover)' : 'var(--surfaces-surface-01)', color: selectedTextColor !== '#1B1F24' ? selectedTextColor : isDropdownDisabled || isDropdownLoading ? 'var(--text-disabled)' : 'var(--text-primary)', + borderRadius: _state.isFocused && '8px', padding: '8px 6px 8px 38px', '&:hover': { backgroundColor: 'var(--interactive-overlays-fill-hover)', @@ -431,6 +433,7 @@ export const DropdownV2 = ({ />
option.value === currentValue)[0] ?? null} diff --git a/frontend/src/Editor/Components/MultiselectV2/MultiselectV2.jsx b/frontend/src/Editor/Components/MultiselectV2/MultiselectV2.jsx index 93c8be1baf..4665430d00 100644 --- a/frontend/src/Editor/Components/MultiselectV2/MultiselectV2.jsx +++ b/frontend/src/Editor/Components/MultiselectV2/MultiselectV2.jsx @@ -12,6 +12,7 @@ import Label from '@/_ui/Label'; const tinycolor = require('tinycolor2'); import { CustomDropdownIndicator, CustomClearIndicator } from '../DropdownV2/DropdownV2'; import { getInputBackgroundColor, getInputBorderColor, getInputFocusedColor } from '../DropdownV2/utils'; +import useStore from '@/AppBuilder/_stores/store'; export const MultiselectV2 = ({ id, @@ -62,6 +63,7 @@ export const MultiselectV2 = ({ const isMandatory = validation?.mandatory ?? false; const multiselectRef = React.useRef(null); const labelRef = React.useRef(null); + const selectRef = React.useRef(null); const [validationStatus, setValidationStatus] = useState( validate(selected?.length ? selected?.map((option) => option.value) : null) ); @@ -74,6 +76,8 @@ export const MultiselectV2 = ({ const [searchInputValue, setSearchInputValue] = useState(''); const _height = padding === 'default' ? `${height}px` : `${height + 4}px`; const [userInteracted, setUserInteracted] = useState(false); + const currentMode = useStore((state) => state.currentMode); + const isEditor = currentMode === 'edit'; const [isMultiselectOpen, setIsMultiselectOpen] = useState(false); useEffect(() => { @@ -281,6 +285,12 @@ export const MultiselectV2 = ({ } }; + const handleClickInEditor = (e) => { + if (e.target.className.includes('clear-indicator') || isMultiselectOpen) return; + e.stopPropagation(); + selectRef.current?.onControlMouseDown(e); + }; + const setInputValue = (values) => { setSelected(values); setExposedVariables({ @@ -457,16 +467,9 @@ export const MultiselectV2 = ({ _width={_width} top={'1px'} /> -
{ - if (!isMultiSelectDisabled) { - fireEvent('onFocus'); - setIsMultiselectOpen(!isMultiselectOpen); - } - }} - > +