File tree 1 file changed +12
-2
lines changed
1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,12 @@ export function useCurrentMode(elementRef: React.RefObject<HTMLElement>) {
36
36
node ,
37
37
node => node . classList . contains ( 'awsui-polaris-dark-mode' ) || node . classList . contains ( 'awsui-dark-mode' )
38
38
) ;
39
- setValue ( darkModeParent ? 'dark' : 'light' ) ;
39
+ const newValue = darkModeParent ? 'dark' : 'light' ;
40
+
41
+ // refer to the comment below in `useReducedMotion`
42
+ if ( newValue !== value ) {
43
+ setValue ( newValue ) ;
44
+ }
40
45
} ) ;
41
46
return value ;
42
47
}
@@ -48,7 +53,12 @@ export function useDensityMode(elementRef: React.RefObject<HTMLElement>) {
48
53
node ,
49
54
node => node . classList . contains ( 'awsui-polaris-compact-mode' ) || node . classList . contains ( 'awsui-compact-mode' )
50
55
) ;
51
- setValue ( compactModeParent ? 'compact' : 'comfortable' ) ;
56
+ const newValue = compactModeParent ? 'compact' : 'comfortable' ;
57
+
58
+ // refer to the comment below in `useReducedMotion`
59
+ if ( newValue !== value ) {
60
+ setValue ( newValue ) ;
61
+ }
52
62
} ) ;
53
63
return value ;
54
64
}
You can’t perform that action at this time.
0 commit comments