-
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
Font Appearance Control: Fix selectedItem downshift uncontrolled prop warning #34721
Merged
andrewserong
merged 2 commits into
trunk
from
fix/font-appearance-control-downshift-error
Sep 14, 2021
Merged
Font Appearance Control: Fix selectedItem downshift uncontrolled prop warning #34721
andrewserong
merged 2 commits into
trunk
from
fix/font-appearance-control-downshift-error
Sep 14, 2021
Conversation
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
andrewserong
added
[Type] Bug
An existing feature does not function as intended
[Feature] Design Tools
Tools that impact the appearance of blocks both to expand the number of tools and improve the experi
labels
Sep 10, 2021
Size Change: +7 B (0%) Total Size: 1.04 MB
ℹ️ View Unchanged
|
glendaviesnz
approved these changes
Sep 13, 2021
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.
This worked for me. Error did not show and menu functioned as expected switching between options.
andrewserong
deleted the
fix/font-appearance-control-downshift-error
branch
September 14, 2021 06:22
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
[Feature] Design Tools
Tools that impact the appearance of blocks both to expand the number of tools and improve the experi
[Type] Bug
An existing feature does not function as intended
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.
Fixes #34524
Description
Following on from #34520, in the Font Appearance Control component, if we don't pass in a selected item to
CustomSelectControl
then that control sets theselectedItem
asundefined
, which then results in a warning in the console fromdownshift
, when we switch between the Default and any other appearance option (or back and forth between them).This is replicable in the TT1-Blocks theme, when selecting the Appearance for the Site Title block in Global Styles, because that theme sets a default value for
fontWeight
but notfontStyle
, which means that its default value doesn't match one of the Font Appearance Control's available values.In this PR, we default to the Default value in the UI if the current value doesn't match one of the available options. This should visually match the existing behaviour on trunk, because the CustomSelectControl component defaults to setting the first item of options as selected. But with this PR applied, we should no longer see the warning in the console.
How has this been tested?
Without this PR applied:
With this PR applied:
Screenshots
The warning in the console looks like this:
With this PR applied, you should be able to switch between appearances without the warning being thrown:
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist:
*.native.js
files for terms that need renaming or removal).