Skip to content

Commit

Permalink
fix(base-modal): resubscribe observer when content node changed
Browse files Browse the repository at this point in the history
  • Loading branch information
reme3d2y committed Jul 2, 2021
1 parent f153178 commit 2fef06e
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions packages/base-modal/src/Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,6 @@ export const BaseModal = forwardRef<HTMLDivElement, BaseModalProps>(
}
};

const contentRef = useCallback((node: HTMLDivElement) => {
if (node !== null) {
contentNodeRef.current = node;
checkToHasScrollBar();
}
}, []);

const shouldRender = keepMounted || open || !exited;

const resizeObserver = useMemo(() => new ResizeObserver(checkToHasScrollBar), []);
Expand All @@ -252,6 +245,17 @@ export const BaseModal = forwardRef<HTMLDivElement, BaseModalProps>(
resizeObserver.disconnect();
}, [resizeObserver]);

const contentRef = useCallback(
(node: HTMLDivElement) => {
if (node !== null) {
contentNodeRef.current = node;
resizeObserver.observe(node);
checkToHasScrollBar();
}
},
[resizeObserver],
);

const handleScroll = useCallback(() => {
if (!scrollableNodeRef.current || !componentRef.current) return;

Expand Down

0 comments on commit 2fef06e

Please sign in to comment.