Skip to content

Commit

Permalink
Fix #5425: CascadeSelect fix for StrictMode
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Nov 28, 2023
1 parent 05f9124 commit f3a9ce9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions components/lib/cascadeselect/CascadeSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
6 changes: 4 additions & 2 deletions components/lib/cascadeselect/CascadeSelectSub.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -173,7 +173,9 @@ export const CascadeSelectSub = React.memo((props) => {
});

useUpdateEffect(() => {
setActiveOptionState(null);
if (!props.parentActive) {
setActiveOptionState(null);
}
}, [props.parentActive]);

const createSubmenu = (option) => {
Expand Down

0 comments on commit f3a9ce9

Please sign in to comment.