Pattern Inserter: Fix bug where the inserter cannot be closed if the user changes pattern category #27792
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.
This PR removes the
key
from PatternInserterPanel so that the component isn't replaced when the selected category changes.Description
As a user, if I open the inserter, click to browse patterns, and then change the pattern category, the SelectControl in PatternInserterPanel loses focus. Because the focus is now outside of the inserter, if I click the inserter button or elsewhere within the post, the inserter is not automatically closed, because the focusOutside of the inserter's useDialog.
Screenshot of the bug
Note that after switching pattern category, the select element loses focus and the inserter cannot be closed via the button or clicking on the post body.
Screenshot of the fix
The fix is to remove the
key
attribute from PatternInserterPanel so that switching pattern category does not cause the whole panel to be replaced, so that the focus is maintained on the select element. This then ensures that clicking the inserter button, or back into the post body, will close the inserter.How has this been tested?
Manually tested in the editor:
+
icon to open the inserter.Patterns
tab.+
icon to close the inserter, or click into the post body to close the inserter.Types of changes
Bug fix:
Checklist:
CC: @youknowriad and @apeatling as I can see you've both touched files related to this feature recently!
Note: I don't have access to merge, so if this fix looks good, can someone please merge it in for me? Thank you! 🙇♂️