-
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
CustomSelectControl V2 legacy adapter: stabilize experimental props #63248
CustomSelectControl V2 legacy adapter: stabilize experimental props #63248
Conversation
Size Change: +48 B (0%) Total Size: 1.75 MB
ℹ️ View Unchanged
|
604400a
to
67b90ea
Compare
@@ -60,56 +85,56 @@ function CustomSelectControl( props: LegacyCustomSelectProps ) { | |||
defaultValue: options[ 0 ]?.name, | |||
} ); | |||
|
|||
const children = options.map( |
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 following block of code is just about changing from mostly __experimentalHint
to hint
, the rest is whitespace-related changes (indentation)
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
> | ||
{ currentHint?.__experimentalHint } | ||
</Styled.SelectedExperimentalHintItem> | ||
{ selectedOptionHint && ( |
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.
Previously, we were rendering this component even where there wasn't a hint to show
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.
Good catch!
packages/components/src/custom-select-control-v2/legacy-component/index.tsx
Outdated
Show resolved
Hide resolved
Flaky tests detected in c0e9f4b. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9842567621
|
packages/components/src/custom-select-control-v2/legacy-component/index.tsx
Outdated
Show resolved
Hide resolved
packages/components/src/custom-select-control-v2/legacy-component/index.tsx
Outdated
Show resolved
Hide resolved
c0e9f4b
to
2c73947
Compare
function applyOptionDeprecations( { | ||
__experimentalHint, | ||
...rest | ||
}: LegacyCustomSelectProps[ 'options' ][ number ] ) { | ||
return { | ||
hint: __experimentalHint, | ||
...rest, | ||
}; | ||
} |
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.
@mirka Relatively to #63248 (comment), I applied your suggestion of adapting the options
array at runtime where necessary
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 v2 legacy stories still use the v1 ones as a base:
gutenberg/packages/components/src/custom-select-control-v2/stories/legacy.story.tsx
Line 15 in 48422a4
import * as V1Story from '../../custom-select-control/stories/index.story'; |
So as a consequence, the options still use the __experimentalHint
prop:
packages/components/src/custom-select-control-v2/legacy-component/index.tsx
Outdated
Show resolved
Hide resolved
> | ||
{ currentHint?.__experimentalHint } | ||
</Styled.SelectedExperimentalHintItem> | ||
{ selectedOptionHint && ( |
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.
Good catch!
That should be ok to leave as-is for now — the Storybook examples will be updated when we remove the downshift-based implementation (see proposed change). It shouldn't otherwise impact the component negatively, since it should be support the older version of the prop for backwards compat. |
…mentalShowSelectedHint
This avoids breakages for any consumer relying on object identity
2c73947
to
4d118af
Compare
But these stories test the v2, so given that we already deprecated the experimental prop, I'd expect we override the options to use the stable prop. Not a deal breaker, but can be confusing right now IMHO. |
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.
LGTM 👍
The deprecated option prop usage in the story is not a blocker IMHO, up to you if you want to address it or not before 🚢
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.
🚀
…ordPress#63248) * CustomSelectControl V2: add showSelectedHint prop, deprecate __experimentalShowSelectedHint * Update showSelectedHint unit tests * CustomSelectControl V2: add hint option prop, deprecate __experimentalHint * Rename __experimentalHint to hint * Refactor to smarter approach * Continue using `__experimentalHint` in the V1 storybook example * CHANGELOG * Add hint to options only if necessary * __experimentalShowSelectedHint => showSelectedHint * Move changelog entry to unreleased section * Give priority to `showSelectedHint` over `__experimentalShowSelectedHint` * Move `__experimentalHint` => `hint` code to run at runtime This avoids breakages for any consumer relying on object identity * Fix wrong link in inline comment --- Co-authored-by: ciampo <mciampini@git.wordpress.org> Co-authored-by: mirka <0mirka00@git.wordpress.org> Co-authored-by: tyxla <tyxla@git.wordpress.org>
What?
Part of #55023
Stabilize the
__experimentalShowSelectedHint
andoptions[]. __experimentalHint
props ofCustomSelectControl
V2 legacy adapter by providing an equivalent, un-prefixed version:showSelectedHint
andoptions[].hint
Why?
As we're about to swap the current V1 implementation with a new implementation based on
ariakit
(ie. the V2 legacy adapter), it's also a good time to stabilize those props in preparation for the swap.Once the swap happens, we will also be able to remove the private
CustomSelectControl
export.How?
By soft-deprecating those props. Existing consumers using those props won't experience any breakages or warnings, but the deprecated props will show as such in the docs.
Testing Instructions
showSelectedHint
prop.__experimentalShowSelectedHint
is not shows anymore✍️ Dev note
See dev note in #63258