Skip to content

Conversation

@adamviktora
Copy link
Contributor

@adamviktora adamviktora commented Apr 3, 2024

What: Closes #10158

I am not sure if the last two commits are necessary. I did them so the <div style="display: contents;"> is not present in the markup and there is no better way to hide it from Popover than by passing both the children and the triggerRef prop to Popover.

@patternfly-build
Copy link
Collaborator

patternfly-build commented Apr 3, 2024

@adamviktora adamviktora changed the title Form group label help feat(FormGroupLabelHelp): update markup to match core Apr 4, 2024
@adamviktora adamviktora requested review from a team, mcoker, nicolethoen and tlabaj and removed request for a team April 4, 2024 09:56
@adamviktora adamviktora marked this pull request as ready for review April 4, 2024 09:58
typeof ref === 'object' && ref !== null && 'current' in ref && ref.current !== undefined;

const handleKeyDown = (event: React.KeyboardEvent<HTMLSpanElement>) => {
if (event.key === 'Enter' && isMutableRef(buttonRef) && buttonRef.current) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should include the Space key here. Buttons natively will be triggered via Enter/Space, while anchor elements only by Enter, and radio/checkbox inputs only by Space.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the insight! I'll include it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just found out the key for Space is " " and we have some hardcoded "Space" keys in the codebase, so I'll replace them with the KeyTypes.Space constant (or the " " string directly in the examples).

Comment on lines 31 to 34
if ([KeyTypes.Space, KeyTypes.Enter].includes(event.key) && isMutableRef(buttonRef) && buttonRef.current) {
buttonRef.current.click();
}
};
Copy link
Contributor

Choose a reason for hiding this comment

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

One last little thing. When pressing Space to trigger the popover in this instance, we'll need to prevent the page from scrolling

@nicolethoen
Copy link
Contributor

Should there be a codemod written for this change?

@thatblindgeye
Copy link
Contributor

@nicolethoen not sure if one will be necessary. The FormGroupLabelHelp was introduced in the v6 branch, and was previously just used to update some examples. Unless we'd want a codemod to check whether labelIcon/labelHelp is being passed a button element/component somewhere and providing a warning about recommending using FormGroupLabelHelp, though again not sure if that would be necessary.

Copy link
Contributor

@kmcfaul kmcfaul left a comment

Choose a reason for hiding this comment

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

LGTM, and I do think the addition of the refs to avoid the popper wrapping div is correct. The wrapping div was an alternate method to get the popper functional, but it's not ideal.

Copy link
Contributor

@thatblindgeye thatblindgeye left a comment

Choose a reason for hiding this comment

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

Looks good CSS wise. From the core perspective:

  • We could remove the aria-described by for the label help button

Deleted second comment as I missed the label-help component being present in Core

@patternfly-build
Copy link
Collaborator

Your changes have been released in:

  • @patternfly/react-code-editor@6.0.0-alpha.56
  • @patternfly/react-core@6.0.0-alpha.56
  • @patternfly/react-docs@7.0.0-alpha.59
  • @patternfly/react-drag-drop@6.0.0-alpha.37
  • @patternfly/react-integration@6.0.0-alpha.27
  • demo-app-ts@5.1.1-alpha.55
  • @patternfly/react-table@6.0.0-alpha.56
  • @patternfly/react-templates@6.0.0-alpha.6

Thanks for your contribution! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FormGroupLabelHelp: use component="span" and isInline to match core

6 participants