Skip to content

Conversation

@mcoker
Copy link
Contributor

@mcoker mcoker commented Aug 26, 2022

fixes #3137

--

I noticed a bunch of other discrepancies between the buttons, so I tried updating all of them to use <CodeEditorControl>, and with @nicolethoen's help, we discovered that passing exitDelay from a state var (isCopied) doesn't work if there are multiple trigger values passed... or something like that. Got a little tricky for me, and our fearless leader @nicolethoen is going to look at it.

This PR

  • adds a new CSS var to control the tooltip maxWidth that widens it a bit
  • adds an object of props/vals we can pass directly to <CodeEditorControl> and individually to <Tooltip> and <Button> to keep the examples consistent
  • Cleans up a bunch of redundant props that don't need to be defined because they're the default
  • Fixes the tooltip on the codesandbox link when you focus on it via keyboard. It needed focus as a value for trigger and for the tooltip to move to the button - wasn't working on the <form>

Some things I noticed that @nicolethoen may clean up with her work, or may need new issues for:

  • <CodeEditor> actions are built using <Tooltip> and <Button> and we have this fancy pants <CodeEditorControl> component, so we have a lot of unnecessary duplication in the code editor, and in this example toolbar. Ideally we would use <CodeEditorControl> for all the things.
  • <CodeEditorControl> has a lot of props that are redundantly redefined or different (that might not need to be?) from <Tooltip>'s defaults. For example
    • entryDelay: 300 is tooltip's default
    • exitDelay: 0 is different (tooltip's is 300) - does it need to be different?
    • position: top is tooltip's default
    • and so on...
    • As a side note, ideally we would just leave all of these redundant props unset if they aren't passed, so <CodeEditorControl> stays in sync with <Tooltip>
  • <CodeEditorControl> hardcodes the tooltip's trigger prop. That should be configurable with a trigger prop on <CodeEditorControl>.
  • You should probably be able to pass tooltipProps or something to <CodeEditorControl> that gets passed along to <Tooltip>.
  • Does <CodeEditorControl> need to set maxWidth: 100px? That's pretty narrow. Could that just use tooltip's default?
  • It's probably covered with the context above, but the example's copy code button needs a tooltip on focus at least.
  • Why don't the exitDelay and "reset tooltip text" times sync up? They're different - they're 1600 exitDelay, and text resets at 2500. If you set them to the same, the text resets before the tooltip disappears. I found this in a few spots:
  • We use execCommand('copy') in all of these places, like https://github.com/patternfly/patternfly-org/blob/main/packages/documentation-framework/helpers/copy.js
    • That's officially deprecated - https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand
    • That method calls for adding a form element to the DOM, and calling .select() on it to copy the text. .select() steals the browser focus, so clicking on the copy button doesn't manage focus the same way other buttons do. IMO, unless the stuff you're copying is 1) in a form element already, and 2) visibly selected, focus should be maintained on the element that triggered the copy command. It's most visible when you click the copy button at the end of any of our examples, then hit tab - that uses copy.js linked above, which appends the form element to <body>, so hitting tab takes you to the "skip to content" button.
    • navigator.clipboard() seems widely supported for regular text anyways. Could we use that instead?

@mcoker mcoker requested review from evwilkin and nicolethoen August 26, 2022 00:25
@patternfly-build
Copy link
Collaborator

Copy link
Member

@evwilkin evwilkin left a comment

Choose a reason for hiding this comment

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

LGTM - thanks for all the cleanup! 💪

@nicolethoen
Copy link
Collaborator

I opened this react issue and am taking a look
patternfly/patternfly-react#7884

@nicolethoen nicolethoen merged commit fab30f5 into patternfly:main Aug 29, 2022
jessiehuff pushed a commit to jessiehuff/patternfly-org that referenced this pull request Oct 24, 2022
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.

Example/demo toolbar item tooltip text breaking

4 participants