-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix missing hook deps in distraction free mode #47611
Conversation
@@ -44,7 +44,7 @@ function Header( { setEntitiesSavedStatesCallback } ) { | |||
select( editPostStore ).isFeatureActive( 'distractionFree' ) && | |||
isLargeViewport, | |||
} ), | |||
[] | |||
[ isLargeViewport ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question. Do we want the other selectors to be re-run when the viewport changes? If not should we decouple this selector and run separately?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine isLargeViewport
is not going to change very often.
documentLabel: postTypeLabel || _x( 'Document', 'noun' ), | ||
}; | ||
}, | ||
[ isLargeViewport ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question as for https://github.com/WordPress/gutenberg/pull/47611/files#r1091830264
@draganescu I'm unsure how to test this to ensure nothing has broken... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix
Any reason for not calculating Something like this: const isDistractionFree = isDistractionFreeMode && isLargeViewport Edit: This isn't a blocker. |
Size Change: +178 B (0%) Total Size: 1.31 MB
ℹ️ View Unchanged
|
Flaky tests detected in a2a1738. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4055794579
|
That would indeed eliminate the need to pass the dependency to the |
@Mamaduka I updated the PR along those lines. |
@@ -127,6 +126,8 @@ function Layout( { styles } ) { | |||
}; | |||
}, [] ); | |||
|
|||
const isDistractionFree = isDistractionFreeMode && isLargeViewport; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meganit: I would do the naming the other way around, leave the select isDistractionFree
as it corresponds to the feature and name the const
isDistractionFreeMode
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😆 😆 Will fix
Actually decided against this as the variable you already had outside the hook was isDistraction
free. Therefore this PR will retain the existing nomenclature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @getdave
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, Dave!
What?
Adds dependency to re-run selectors if viewport changes.
Why?
See review comments in #45591 (comment)
How?
Add
isLargeViewport
touseSelect
deps.Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast