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

BaseControl: Help text id has undefined value if no id is passed to component #35899

Merged
merged 1 commit into from
Oct 25, 2021
Merged

BaseControl: Help text id has undefined value if no id is passed to component #35899

merged 1 commit into from
Oct 25, 2021

Conversation

t-hamano
Copy link
Contributor

@t-hamano t-hamano commented Oct 24, 2021

Description

As shown in the sample code in the Handbook, the id given to the help text will be undefined if you do not pass an id to the BaseControl component and pass an help text.

Handbook Sample Code

import { BaseControl } from '@wordpress/components';
 
const MyBaseControl = () => (
    <BaseControl help="Pressing the Select an author button will open a modal that allows an advanced mechanism for author selection">
        <BaseControl.VisualLabel>Author</BaseControl.VisualLabel>
        <Button>Select an author</Button>
    </BaseControl>
);

Rendering result

undefined_help_id

This PR adds a check to see if id is defined when rendering the help text.

Types of changes

Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR (please manually search all *.native.js files for terms that need renaming or removal).

Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

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

The solution looks good. Thanks for contributing, @t-hamano.

@Mamaduka Mamaduka merged commit a95ca3e into WordPress:trunk Oct 25, 2021
@github-actions github-actions bot added this to the Gutenberg 11.9 milestone Oct 25, 2021
@t-hamano t-hamano deleted the fix/basecontrol-help-id branch October 25, 2021 13:15
@andrewserong andrewserong added the [Type] Bug An existing feature does not function as intended label Nov 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants