diff --git a/components/lib/cascadeselect/CascadeSelect.js b/components/lib/cascadeselect/CascadeSelect.js index fbcae4670c..e7291fa3f4 100644 --- a/components/lib/cascadeselect/CascadeSelect.js +++ b/components/lib/cascadeselect/CascadeSelect.js @@ -401,6 +401,7 @@ export const CascadeSelect = React.memo( optionGroupIcon={props.optionGroupIcon} optionLabel={props.optionLabel} optionValue={props.optionValue} + parentActive={props.value != null} level={0} optionGroupLabel={props.optionGroupLabel} optionGroupChildren={props.optionGroupChildren} diff --git a/components/lib/cascadeselect/CascadeSelectSub.js b/components/lib/cascadeselect/CascadeSelectSub.js index 803e691cdf..a80d179390 100644 --- a/components/lib/cascadeselect/CascadeSelectSub.js +++ b/components/lib/cascadeselect/CascadeSelectSub.js @@ -5,7 +5,7 @@ import { AngleRightIcon } from '../icons/angleright'; import { Ripple } from '../ripple/Ripple'; import { DomHandler, IconUtils, ObjectUtils, classNames, mergeProps } from '../utils/Utils'; export const CascadeSelectSub = React.memo((props) => { - const [activeOptionState, setActiveOptionState] = React.useState(null); + const [activeOptionState, setActiveOptionState] = React.useState(props.parentActive); const elementRef = React.useRef(null); const context = React.useContext(PrimeReactContext); const { ptm, cx } = props; @@ -173,7 +173,9 @@ export const CascadeSelectSub = React.memo((props) => { }); useUpdateEffect(() => { - setActiveOptionState(null); + if (!props.parentActive) { + setActiveOptionState(null); + } }, [props.parentActive]); const createSubmenu = (option) => {