@@ -60,12 +60,21 @@ export const ActionsWrapper = ({
60
60
if ( ! ref . current || ! containerWidth || ! wrappedClass ) {
61
61
return ;
62
62
}
63
- const isRtl = getIsRtl ( ref . current ) ;
64
- const { offsetWidth, offsetLeft } = ref . current ;
65
- const start = isRtl ? containerWidth - offsetWidth - offsetLeft : offsetLeft ;
66
- // if the action slot is towards the left (right in RTL) of its container
67
- setWrapped ( start < 100 ) ;
68
- } , [ containerWidth , wrappedClass ] ) ;
63
+ function check ( ) {
64
+ const isRtl = getIsRtl ( ref . current ) ;
65
+ const { offsetWidth, offsetLeft } = ref . current ! ;
66
+ const start = isRtl ? containerWidth ! - offsetWidth - offsetLeft : offsetLeft ;
67
+ // if the action slot is towards the left (right in RTL) of its container
68
+ setWrapped ( start < 100 ) ;
69
+ }
70
+
71
+ // Discovered actions are rendered by their plugin, so don't cause a
72
+ // re-render of our React tree. So we observe for changes.
73
+ const observer = new MutationObserver ( check ) ;
74
+ observer . observe ( ref . current , { attributes : false , childList : true , subtree : true } ) ;
75
+ check ( ) ;
76
+ return ( ) => observer . disconnect ( ) ;
77
+ } ) ;
69
78
const actionButton = createActionButton ( testUtilClasses , action , buttonText , onButtonClick ) ;
70
79
if ( ! actionButton && discoveredActions . length === 0 ) {
71
80
return null ;
0 commit comments