-
Notifications
You must be signed in to change notification settings - Fork 4.7k
CustomSelect: Adapt component for legacy props #57902
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
64c2947
Move components to own files
brookewp 4250494
Add legacy adapter
brookewp d3da53a
Add legacy tests
brookewp c3d6a80
Update naming and remove unnecessary tests
brookewp 4c9f32f
Add legacy props to adapter
brookewp 7d9bc28
Create new component to forward store
brookewp d2b30d6
Create legacy component
brookewp 905b9fe
Remove useDeprecatedProps hook and update adapter
brookewp 940cdaf
Separate stories
brookewp 82b33d1
Update stories and types
brookewp f1b5320
Convert function into variable instead
brookewp c3f4a23
Update legacy changeObject to match existing properties
brookewp a98e38c
Add tests for onChange function
brookewp 09e9c47
add rest of legacy props
brookewp 80158a6
Update sizing
brookewp 2ccdc91
Memoize selected render value
brookewp 46283b5
Remove deprecated prop to fix test failures
brookewp 2526b8e
Add `unmountOnHide` and require `defaultValue` as a result
brookewp a8b4e8a
Update styling for experimental hint
brookewp bc1cbe7
Connect CustomSelectButton to context system for legacy sizing
brookewp 002bd2e
Update sizing logic and types
brookewp 85993fd
Fix styling to match legacy including hints
brookewp 1524180
Clean up props
brookewp eb4e946
Omit ‘onChange’ from WordPressComponentProps to prevent conflict
brookewp fdabba7
Update checkmark icon
brookewp 2bc69ef
Update select arrow
brookewp 63c3dd4
Update types
brookewp 1280774
Add static typing test
brookewp d25764b
Update story for better manual testing
brookewp 18e15e9
Control mount state for legacy keyboard behaviour
brookewp e0caf2d
Remove export that is no longer needed
brookewp cafbdf8
Update legacy onChange type
brookewp 7b86a97
Update tests
brookewp bc7027e
Update naming
brookewp 4f9f6f9
Try mounting on first render to avoid required defaultValue
brookewp 71b2c1a
Add WordPressComponentProps to default export
brookewp be17780
Update types
brookewp 287c354
Replace RTL/userEvent with ariakit/test
brookewp 7eb2134
Remove unmountOnHide and related logic for first iteration
brookewp c794d06
Update docs
brookewp 5c58f78
Update naming
brookewp c73ce18
Merge new tests and update to ariakit/test
brookewp 795df54
Fix typo in readme
mirka 4171c67
Legacy: Clean up stories
mirka 8d70b4f
Default: Clean up stories
mirka cb88b8b
Add todo comment about BaseControl
mirka d2dfe8b
Fix styles
mirka ddc8e6b
Rename styled components for consistency
mirka faa6d7b
Fix typo in readme
mirka 797e139
Merge branch 'trunk' into add/legacy-adapter-customselectcontrol
mirka f8446f8
Rename for clarity
mirka 3a2be41
Update changelog
mirka 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
Remove useDeprecatedProps hook and update adapter
- Loading branch information
commit 905b9feda7c50dd8cf46f872c81d3a8521097095
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| /** | ||
| * Internal dependencies | ||
| */ | ||
| export { LegacyAdapter as CustomSelect } from './legacy-adapter'; | ||
| export { DefaultExport as CustomSelect } from './legacy-adapter'; | ||
| export { default as CustomSelectItem } from './custom-select-item'; |
24 changes: 16 additions & 8 deletions
24
packages/components/src/custom-select-control-v2/legacy-adapter.tsx
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,23 @@ | ||
| /** | ||
| * Internal dependencies | ||
| */ | ||
| import CustomSelect from './custom-select'; | ||
| import type { LegacyCustomSelectProps } from './types'; | ||
| import { useDeprecatedProps } from './use-deprecated-props'; | ||
| import _LegacyCustomSelect from './legacy-component'; | ||
| import _NewCustomSelect from './default-component'; | ||
| import type { CustomSelectProps, LegacyCustomSelectProps } from './types'; | ||
|
|
||
| export function LegacyAdapter( props: LegacyCustomSelectProps ) { | ||
| function isLegacy( props: any ): props is LegacyCustomSelectProps { | ||
| return ( | ||
| <CustomSelect | ||
| { ...useDeprecatedProps( props ) } | ||
| hideLabelFromVision={ props.hideLabelFromVision } | ||
| /> | ||
| typeof props.options !== 'undefined' || | ||
| props.__experimentalShowSelectedHint !== undefined | ||
| ); | ||
| } | ||
|
|
||
| export function DefaultExport( | ||
| props: LegacyCustomSelectProps | CustomSelectProps | ||
brookewp marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) { | ||
| if ( isLegacy( props ) ) { | ||
| return <_LegacyCustomSelect { ...props } />; | ||
| } | ||
|
|
||
| return <_NewCustomSelect { ...props } />; | ||
| } | ||
This file contains hidden or 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
96 changes: 0 additions & 96 deletions
96
packages/components/src/custom-select-control-v2/use-deprecated-props.tsx
This file was deleted.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.