Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add deprecated legacy props describedBy and __nextUnconstrainedWidth
  • Loading branch information
brookewp committed Jan 11, 2024
commit 6a8b385e0c7673698045dc31fedad93575e01a05
13 changes: 13 additions & 0 deletions packages/components/src/custom-select-control-v2/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ export type LegacyCustomSelectProps = {
*
*/
hideLabelFromVision?: boolean;
/**
* Pass in a description that will be shown to screen readers associated with the
* select trigger button. If no value is passed, the text "Currently selected:
* selectedItem.name" will be used fully translated.
*/
describedBy?: string;
/**
* Label for the control.
*/
Expand All @@ -100,6 +106,13 @@ export type LegacyCustomSelectProps = {
*/
value?: Option;
__experimentalShowSelectedHint?: boolean;
/**
* Opt-in prop for an unconstrained width style which became the default in
* WordPress 6.4. The prop is no longer needed and can be safely removed.
*
* @deprecated
*/
__nextUnconstrainedWidth?: boolean;
};

export type CustomSelectItemProps = {
Expand Down
Copy link
Contributor Author

@brookewp brookewp Dec 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still need to mark the props as to be deprecated, if we decide we want to go with this option

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useCallback } from '@wordpress/element';
*/
import { CustomSelectItem } from '.';
import type { CustomSelectProps, LegacyCustomSelectProps } from './types';
import deprecated from '@wordpress/deprecated';

function isLegacyProps( props: any ): props is LegacyCustomSelectProps {
return (
Expand Down Expand Up @@ -60,7 +61,22 @@ export function useDeprecatedProps(
);

if ( isLegacyProps( props ) ) {
if ( props.__nextUnconstrainedWidth ) {
deprecated(
'Constrained width styles for wp.components.CustomSelectControl',
{
hint: 'This behaviour is now built-in.',
since: '6.4',
}
);
}

const legacyProps = {
'aria-describedby': props.describedBy,
};

return {
...legacyProps,
children: transformOptionsToChildren( props ),
label: props.label ?? '',
onChange: legacyChangeHandler,
Expand Down