Skip to content

Conversation

@Mamaduka
Copy link
Member

What?

Closes #69925.
Similar to #66855.

PR fixes active ToggleGroupControlOption background when an empty string is provided, which seems to be a valid case, but was omitted from the check.

Testing Instructions

  1. Run a test plugin via DevTools console.
  2. Confirm that the "None" option is correctly selected.
  3. Switching between options works as before.
Details

const {createElement: el, useState} = wp.element;
const {__experimentalToggleGroupControl: ToggleGroupControl, __experimentalToggleGroupControlOption: ToggleGroupControlOption} = wp.components;
const registerPlugin = wp.plugins.registerPlugin;
const PluginDocumentSettingPanel = wp.editor.PluginDocumentSettingPanel;

function TestToggleGroupControl() {
    const [value,setValue] = useState('');

    console.log(value);

    return el(PluginDocumentSettingPanel, {
        className: 'test-custom-select',
        title: 'Test Toggle Group Control',
        name: 'test-toggle-group-control'
    }, el(ToggleGroupControl, {
        label: "Test",
        value: value,
        isBlock: true,
        __nextHasNoMarginBottom: true,
        __next40pxDefaultSize: true,
        onChange: setValue
    }, el(ToggleGroupControlOption, {
        value: "",
        label: "None"
    }), el(ToggleGroupControlOption, {
        value: "next",
        label: "Next"
    })));
}

registerPlugin('test-toggle-group-control', {
    render: TestToggleGroupControl,
});

Testing Instructions for Keyboard

Same.

Screenshots or screencast

CleanShot 2025-04-22 at 22 51 30

@Mamaduka Mamaduka added [Type] Bug An existing feature does not function as intended [Feature] UI Components Impacts or related to the UI component system [Package] Components /packages/components labels Apr 22, 2025
@Mamaduka Mamaduka self-assigned this Apr 22, 2025
@Mamaduka Mamaduka requested a review from ajitbohra as a code owner April 22, 2025 18:54
@github-actions
Copy link

github-actions bot commented Apr 22, 2025

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 props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @spstrap.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: spstrap.

Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: Sourav61 <[email protected]>
Co-authored-by: mirka <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

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

LGTM!

  • Is it worth backporting this PR into 6.8.x release? See #69925 (comment)
  • I'm not sure why the component changelog entry check is failing, but the change log entry should have been added correctly.

@Mamaduka
Copy link
Member Author

Is it worth backporting this PR into 6.8.x release?

Yes. It's not a major refactoring.

I'm not sure why the component changelog entry check is failing, but the change log entry should have been added correctly.

Same. It could be a problem with the workflow. I'll keep an eye on it.

@Mamaduka Mamaduka added the Backport to WP Minor Release Pull request that needs to be backported to a WordPress minor release label Apr 23, 2025
@Mamaduka Mamaduka merged commit accde16 into trunk Apr 23, 2025
63 of 64 checks passed
@Mamaduka Mamaduka deleted the fix/toggle-group-control-empty-string-value branch April 23, 2025 06:19
@github-actions github-actions bot added this to the Gutenberg 20.8 milestone Apr 23, 2025
@t-hamano t-hamano moved this from 🔎 Needs Review to ✅ Done in WordPress 6.8.x Editor Tasks Apr 23, 2025
t-hamano added a commit that referenced this pull request Apr 28, 2025
)

Unlinked contributors: spstrap.

Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: Sourav61 <[email protected]>
Co-authored-by: mirka <[email protected]>
@t-hamano
Copy link
Contributor

A backport PR for the wp/6.8 branch: #70000

t-hamano added a commit that referenced this pull request Apr 28, 2025
)

Unlinked contributors: spstrap.

Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: Sourav61 <[email protected]>
Co-authored-by: mirka <[email protected]>
t-hamano added a commit that referenced this pull request Apr 28, 2025
) (#70000)

Unlinked contributors: spstrap.

Co-authored-by: George Mamadashvili <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: Sourav61 <[email protected]>
Co-authored-by: mirka <[email protected]>
@t-hamano
Copy link
Contributor

Removing the Backport to WP Minor Release label as #70000 has just been merged into the wp/6.8 branch.

@t-hamano t-hamano removed the Backport to WP Minor Release Pull request that needs to be backported to a WordPress minor release label Apr 28, 2025
chriszarate pushed a commit to chriszarate/gutenberg that referenced this pull request Jul 1, 2025
…dPress#69969)

Unlinked contributors: spstrap.

Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: Sourav61 <[email protected]>
Co-authored-by: mirka <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] UI Components Impacts or related to the UI component system [Package] Components /packages/components [Type] Bug An existing feature does not function as intended

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

ToggleGroupControlOption with an empty string ("") value does not display as selected

3 participants