From 902c2a9d77a6defa1b9dd93956804212cfeab3db Mon Sep 17 00:00:00 2001 From: devanshu052000 Date: Mon, 24 Mar 2025 23:03:18 +0530 Subject: [PATCH] Fix onClick behaviour in editor and preview mode. --- .../Components/DropdownV2/DropdownV2.jsx | 19 +++++++++++++-- .../MultiselectV2/MultiselectV2.jsx | 23 +++++++++++-------- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/frontend/src/Editor/Components/DropdownV2/DropdownV2.jsx b/frontend/src/Editor/Components/DropdownV2/DropdownV2.jsx index b2445435c0..feb3087920 100644 --- a/frontend/src/Editor/Components/DropdownV2/DropdownV2.jsx +++ b/frontend/src/Editor/Components/DropdownV2/DropdownV2.jsx @@ -15,6 +15,7 @@ import Label from '@/_ui/Label'; import cx from 'classnames'; import { getInputBackgroundColor, getInputBorderColor, getInputFocusedColor } from './utils'; import { isMobileDevice } from '@/_helpers/appUtils'; +import useStore from '@/AppBuilder/_stores/store'; const { DropdownIndicator, ClearIndicator } = components; const INDICATOR_CONTAINER_WIDTH = 60; @@ -39,7 +40,7 @@ export const CustomDropdownIndicator = (props) => { export const CustomClearIndicator = (props) => { return ( - + ); }; @@ -96,11 +97,14 @@ export const DropdownV2 = ({ const { isValid, validationError } = validationStatus; const ref = React.useRef(null); const dropdownRef = React.useRef(null); + const selectRef = React.useRef(null); const [visibility, setVisibility] = useState(properties.visibility); const [isDropdownLoading, setIsDropdownLoading] = useState(dropdownLoadingState); const [isDropdownDisabled, setIsDropdownDisabled] = useState(disabledState); const [searchInputValue, setSearchInputValue] = useState(''); const [userInteracted, setUserInteracted] = useState(false); + const currentMode = useStore((state) => state.currentMode); + const isEditor = currentMode === 'edit'; const _height = padding === 'default' ? `${height}px` : `${height + 4}px`; const labelRef = useRef(); @@ -167,6 +171,12 @@ export const DropdownV2 = ({ setExposedVariable('isValid', validationStatus?.isValid); }; + const handleClickInEditor = (e) => { + if (e.target.className.includes('clear-indicator') || isMenuOpen) return; + e.stopPropagation(); + selectRef.current?.onControlMouseDown(e); + }; + useEffect(() => { setInputValue(findDefaultItem(advanced ? schema : options)); // eslint-disable-next-line react-hooks/exhaustive-deps @@ -431,8 +441,13 @@ export const DropdownV2 = ({ _width={_width} top={'1px'} /> -
+
{ - fireEvent('onFocus'); setIsMultiselectOpen(true); + fireEvent('onFocus'); }} onMenuClose={() => { setIsMultiselectOpen(false);