File tree Expand file tree Collapse file tree 1 file changed +23
-10
lines changed
packages/compass-components/src/components Expand file tree Collapse file tree 1 file changed +23
-10
lines changed Original file line number Diff line number Diff line change @@ -278,16 +278,29 @@ export const DrawerAnchor: React.FunctionComponent = ({ children }) => {
278278 Record < string , HTMLButtonElement | undefined >
279279 > ( { } ) ;
280280
281- useEffect ( function ( ) {
282- const nodes : Record < string , HTMLButtonElement | undefined > = { } ;
283- for ( const [ index , item ] of toolbarData . entries ( ) ) {
284- const button = document . querySelector (
285- `[data-testid="lg-drawer-toolbar-icon_button-${ index } "]`
286- ) ;
287- nodes [ item . id ] = button ? ( button as HTMLButtonElement ) : undefined ;
288- }
289- setAssistantNodes ( nodes ) ;
290- } ) ;
281+ useEffect (
282+ function ( ) {
283+ const nodes : Record < string , HTMLButtonElement | undefined > = { } ;
284+ for ( const [ index , item ] of toolbarData . entries ( ) ) {
285+ const button = document . querySelector (
286+ `[data-testid="lg-drawer-toolbar-icon_button-${ index } "]`
287+ ) ;
288+ if ( button ) {
289+ nodes [ item . id ] = button as HTMLButtonElement ;
290+ }
291+ }
292+
293+ setAssistantNodes ( ( oldNodes ) => {
294+ for ( const id of Object . keys ( nodes ) ) {
295+ if ( nodes [ id ] !== oldNodes [ id ] ) {
296+ return nodes ;
297+ }
298+ }
299+ return oldNodes ;
300+ } ) ;
301+ } ,
302+ [ toolbarData , assistantNodes ]
303+ ) ;
291304
292305 return (
293306 < >
You can’t perform that action at this time.
0 commit comments