-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Closed
Labels
[Package] Components/packages/components/packages/components[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended
Description
Description
Often times we will use an empty string as default value for post meta, and previously the ToggleGroupControlOption worked correctly, after 6.8 update though it fails to show a selected option with value="", and renders no background color (so makes the control invisible as text is same color as background).
Step-by-step reproduction instructions
register_post_meta(
'',
'title-display',
[
'type' => 'string',
'description' => 'Determines whether to show the page title or not',
'single' => true,
'default' => '',
'sanitize_callback' => fn (mixed $value): string => $value === 'hide' ? $value : '',
'auth_callback' => fn (): bool => current_user_can('edit_posts'),
'show_in_rest' => true,
],
);
function show_title(?int $id = null): bool
{
return get_post_meta($id ?: get_the_ID(), 'title-display', true) === '';
}<ToggleGroupControl
label="Title display"
value={value}
onChange={setValue}
__nextHasNoMarginBottom
__next40pxDefaultSize
>
<ToggleGroupControlOption
value=""
label="Show"
/>
<ToggleGroupControlOption
value="hide"
label="Hide"
/>
</ToggleGroupControl>Screenshots, screen recording, code snippet
Environment info
- WordPress 6.8
Please confirm that you have searched existing issues in the repo.
- Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
- Yes
Please confirm which theme type you used for testing.
- Block
- Classic
- Hybrid (e.g. classic with theme.json)
- Not sure
Metadata
Metadata
Assignees
Labels
[Package] Components/packages/components/packages/components[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended

