-
Notifications
You must be signed in to change notification settings - Fork 14
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
feat(PPDSC-2117): tooltip panel and content #204
Conversation
You can preview these changes on: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about adding a warning message on prod env:
Note 🚨: If the Tooltip is wrapping a functional component, the functional component needs to accept a ref using forwardRef.
Is it necessary? I am not sure how to test it though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job @Xin00163 👏 and all the examples in storybook are 💯
return <Button {...props} size={size} overrides={iconButtonSettings} />; | ||
}; | ||
return ( | ||
<Button {...props} size={size} ref={ref} overrides={iconButtonSettings} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth adding a test for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely
src/tooltip/tooltip.tsx
Outdated
overrides, | ||
...props | ||
}) => { | ||
const [open, setOpenState] = useControlled({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this just be setOpen
? by convention. Is it for changing open
🤔 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it's more concise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would stick to the convention of UseState, if applicable, is more readable: https://reactjs.org/docs/hooks-state.html. Is the one we are using in the repo. [stateName, setStateName]
src/tooltip/tooltip.tsx
Outdated
// If tooltip is used as a label, add aria-labelledby to childrenProps and id to StyledTooltip; | ||
// Because of above, 'aria-describedby' has different id for reference and floating, hence manually set below as well; | ||
const id = useId(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think would be good mention to Mike the scenario of a button with an emoji
as a text! So we can explain in the documentation when they should do as such 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I will update the docs with more details
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this gonna be done in an already existing ticket? can we add it in the ticket if so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No there isn't one. Let's finish building tooltip first, then we can build docs.
Looks good, just shared with you that issue with aria-label. Worth ticking the checkboxes once done, especially the one about Screen Readers! 😬 |
So as a result, we will need to make |
src/tooltip/tooltip.tsx
Outdated
@@ -53,13 +53,17 @@ const ThemelessTooltip: React.FC<TooltipProps> = ({ | |||
// Because of above, 'aria-describedby' has different id for reference and floating, hence manually set below as well; | |||
const id = useId(); | |||
|
|||
const titleIsString = typeof title === 'string'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isTitleString
I would personally go for isTitleString
. That's the convention for boolean. is interrogative 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind. I did see childrenIsString
and testSvgCodeIsString
so don't think we are following this convention
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, unfortunately not. I think we should but ok 👍
const labelOrDescProps = {} as { | ||
'aria-label'?: string | null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I know.I think this should be instead:
const labelOrDescProps: {
'aria-label'?: string | null;
'aria-labelledby'?: string | null;
'aria-describedby'?: string | null;
} = {}
As it is now, you are "forcing it to be as.. "
src/tooltip/tooltip.tsx
Outdated
labelOrDescProps['aria-label'] = titleIsString ? title : null; | ||
labelOrDescProps['aria-labelledby'] = open && !titleIsString ? id : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which scenarios are these covering? why do we need both? Maybe add some comments would be helpful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a comment above but let me know if it's not clear
Can we please use the checkboxes? and use N/a if not applicable? I think we should start getting used to those, if we want to keep them.. they would have helped to find the issue with the aria label. |
src/tooltip/tooltip.tsx
Outdated
@@ -53,13 +53,17 @@ const ThemelessTooltip: React.FC<TooltipProps> = ({ | |||
// Because of above, 'aria-describedby' has different id for reference and floating, hence manually set below as well; | |||
const id = useId(); | |||
|
|||
const titleIsString = typeof title === 'string'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, unfortunately not. I think we should but ok 👍
* fix(PPDSC-2117): wip * feat(PPDSC-2117): add tooltip * fix(PPDSC-2117): add forwardRef to iconButton and update tests * fix(PPDSC-2117): add to index.ts * fix(PPDSC-2117): address comments * fix(PPDSC-2117): address comments * fix(PPDSC-2117): address reviews * fix(PPDSC-2117): a11y test * fix(PPDSC-2117): naming and comment * fix(PPDSC-2117): design feedback
PPDSC-2117
aria-labelledby
attribute floating-ui/floating-ui#1704onDismiss
oronOpen
props because it seems unnecessary for tooltip.Note 🚨: If the Tooltip is wrapping a functional component, the functional component needs to accept a ref using forwardRef.
I have done:
I have tested manually:
Before:
After:
Who should review this PR:
How to test: