Skip to content
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

Fix ToggleGroupControlOption not passing ref to the underlying element #35546

Merged
merged 3 commits into from
Oct 13, 2021

Conversation

diegohaz
Copy link
Member

This PR is a small fix to avoid future issues.

The internal ToggleGroupControlButton component doesn't accept a ref prop. Instead, it expects to receive forwardedRef:

Because of this, passing ref to ToggleGroupControlOption wouldn't work.

@diegohaz diegohaz self-assigned this Oct 12, 2021
@diegohaz diegohaz added [Package] Components /packages/components [Type] Bug An existing feature does not function as intended labels Oct 12, 2021
@diegohaz diegohaz requested a review from mirka October 12, 2021 12:14
Copy link
Contributor

@ntsekouras ntsekouras left a comment

Choose a reason for hiding this comment

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

Thanks for the fix!

@ciampo
Copy link
Contributor

ciampo commented Oct 12, 2021

Out of curiosity, would using React.forwardRef be a cleaner solution instead of having a prop called forwardedRef?

@ciampo ciampo added this to In progress (owned) ⏳ in WordPress Components via automation Oct 12, 2021
@diegohaz
Copy link
Member Author

Since this component is not exposed, I'm okay with the forwardedRef prop. But we can refactor it so all the logic is inside ToggleGroupControlOption. And then delete ToggleGroupControlButton to simplify the code.

@ciampo
Copy link
Contributor

ciampo commented Oct 13, 2021

Since this component is not exposed, I'm okay with the forwardedRef prop. But we can refactor it so all the logic is inside ToggleGroupControlOption. And then delete ToggleGroupControlButton to simplify the code.

Makes sense.

We should merge this PR to get the fix in the codebase and then open a follow-up PR to merge ToggleGroupControlButton into ToggleGroupControlOption (let me know if you'd prefer to work on it directly, otherwise I can work on it myself).

@diegohaz diegohaz merged commit c906e26 into trunk Oct 13, 2021
@diegohaz diegohaz deleted the fix/toggle-group-control-option-ref branch October 13, 2021 10:45
WordPress Components automation moved this from In progress (owned) ⏳ to Done 🎉 Oct 13, 2021
@github-actions github-actions bot added this to the Gutenberg 11.8 milestone Oct 13, 2021
@ciampo
Copy link
Contributor

ciampo commented Oct 13, 2021

We should merge this PR to get the fix in the codebase and then open a follow-up PR to merge ToggleGroupControlButton into ToggleGroupControlOption

I will take care of this and open a PR soon

Update: Opened #35600

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Components /packages/components [Type] Bug An existing feature does not function as intended
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants