Skip to content

Commit

Permalink
Fix primefaces#3811: Sidebar toggle dissmissable state
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Dec 23, 2022
1 parent b7b87fb commit 415d158
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion components/lib/sidebar/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { CSSTransition } from '../csstransition/CSSTransition';
import { useEventListener, useMountEffect, useUnmountEffect, useUpdateEffect } from '../hooks/Hooks';
import { Portal } from '../portal/Portal';
import { Ripple } from '../ripple/Ripple';
import { classNames, DomHandler, ObjectUtils, ZIndexUtils } from '../utils/Utils';
import { DomHandler, ObjectUtils, ZIndexUtils, classNames } from '../utils/Utils';

export const Sidebar = React.forwardRef((props, ref) => {
const [maskVisibleState, setMaskVisibleState] = React.useState(false);
Expand Down Expand Up @@ -140,6 +140,17 @@ export const Sidebar = React.forwardRef((props, ref) => {
}
}, [maskVisibleState]);

useUpdateEffect(() => {
// #3811 if dismissible state is toggled while open we must unregister and re-regisetr
if (visibleState) {
unbindDocumentClickListener();

if (props.dismissable && !props.modal) {
bindDocumentClickListener();
}
}
}, [props.dismissable, props.modal, visibleState]);

useUnmountEffect(() => {
disableDocumentSettings();
maskRef.current && ZIndexUtils.clear(maskRef.current);
Expand Down

0 comments on commit 415d158

Please sign in to comment.