Skip to content

Commit

Permalink
chore: Apply act warning fix to all hooks that uses useMutationObserv…
Browse files Browse the repository at this point in the history
…er (#104)
  • Loading branch information
taheramr authored Oct 29, 2024
1 parent 2b188cf commit f6b9728
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/internal/visual-mode/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ export function useCurrentMode(elementRef: React.RefObject<HTMLElement>) {
node,
node => node.classList.contains('awsui-polaris-dark-mode') || node.classList.contains('awsui-dark-mode')
);
setValue(darkModeParent ? 'dark' : 'light');
const newValue = darkModeParent ? 'dark' : 'light';

// refer to the comment below in `useReducedMotion`
if (newValue !== value) {
setValue(newValue);
}
});
return value;
}
Expand All @@ -48,7 +53,12 @@ export function useDensityMode(elementRef: React.RefObject<HTMLElement>) {
node,
node => node.classList.contains('awsui-polaris-compact-mode') || node.classList.contains('awsui-compact-mode')
);
setValue(compactModeParent ? 'compact' : 'comfortable');
const newValue = compactModeParent ? 'compact' : 'comfortable';

// refer to the comment below in `useReducedMotion`
if (newValue !== value) {
setValue(newValue);
}
});
return value;
}
Expand Down

0 comments on commit f6b9728

Please sign in to comment.