-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
edit-post: After closing welcome and content is empty, focus title field #40195
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c4ddf1e
Posts: Make sure to focus title after welcome dialog close if empty.
alexstine 534e15a
Use a ref to control focus on welcome close.
alexstine 7fb70c4
Add E2E test coverage.
alexstine c2d4946
Code optimizing. Try to fix E2E tests.
alexstine b858bf8
Reviewer feedback.
alexstine d3ea07b
Move isCleanNewPost to edit-post useEffect.
alexstine 929835f
Only pull initial value of isCleanNewPost.
alexstine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
A side effect of adding the value of
isCleanNewPost
as a dependency here is that the effect will run ifisCleanNewPost
changes even ifisWelcomeGuideVisible
didn't change. Meaning if the post was not clear but becomes clean (could happen programmatically for instance) while the welcome guide is open, the title will be focused and the welcome guide closes (focus moved outside).The probably of the above happening is small of course but I think there's a better way to implement this logic. (Calling the selector inside the effect).
So you'd select the selector by doing :
and then in the effect, you'd replace
! isCleanNewPost
with! isCleanNewPost()
instead.Note that this technique of calling selectors outside of
useSelect
should only be used if the returned value is not used in the rendering of the React tree but in an effect or event handler or any random callback.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.
@youknowriad I get this error.
What should I do?
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.
Actually, I guess it will not work. I generated a local build and this was logged in console.
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.
The useSelect call shouldn't be inside the callback but it should just replace the existing one line 116
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.
Ah, okay. Fixed. Just the 1 call to
useSelect( store_name );
retrieves once, yes? That way, once it is retrieved, it will not trigger the effect again?