Skip to content

Commit 1bbf47b

Browse files
committed
chore: refined the condition
1 parent 6558a01 commit 1bbf47b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/app-layout/visual-refresh-toolbar/state/use-ai-drawer.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,15 @@ export function useAiDrawer({
3636
aiDrawerWasOpenRef.current = aiDrawerWasOpenRef.current || !!activeAiDrawerId;
3737
const prevExpandedDrawerId = usePrevious(expandedDrawerId);
3838

39+
const aiDrawer = runtimeDrawer && mapRuntimeConfigToAiDrawer(runtimeDrawer);
40+
3941
useEffect(() => {
40-
if (prevExpandedDrawerId !== expandedDrawerId) {
42+
if (prevExpandedDrawerId !== expandedDrawerId && (expandedDrawerId === aiDrawer?.id || expandedDrawerId === null)) {
4143
fireNonCancelableEvent(runtimeDrawer?.onToggleFocusMode, {
4244
isExpanded: !!expandedDrawerId,
4345
});
4446
}
45-
}, [runtimeDrawer?.onToggleFocusMode, expandedDrawerId, prevExpandedDrawerId]);
47+
}, [runtimeDrawer?.onToggleFocusMode, expandedDrawerId, prevExpandedDrawerId, aiDrawer]);
4648

4749
function onActiveAiDrawerResize(size: number) {
4850
const limitedSize = getLimitedValue(minAiDrawerSize, size, getMaxAiDrawerSize());
@@ -96,7 +98,6 @@ export function useAiDrawer({
9698
}
9799
}
98100

99-
const aiDrawer = runtimeDrawer && mapRuntimeConfigToAiDrawer(runtimeDrawer);
100101
const activeAiDrawer = activeAiDrawerId && activeAiDrawerId === aiDrawer?.id ? aiDrawer : null;
101102
const activeAiDrawerSize = activeAiDrawerId ? (size ?? activeAiDrawer?.defaultSize ?? MIN_DRAWER_SIZE) : 0;
102103
const minAiDrawerSize = Math.min(activeAiDrawer?.defaultSize ?? MIN_DRAWER_SIZE, MIN_DRAWER_SIZE);

0 commit comments

Comments
 (0)