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

feat(PPDSC-2117): tooltip panel and content #204

Merged
merged 14 commits into from
May 25, 2022

Conversation

Xin00163
Copy link
Contributor

@Xin00163 Xin00163 commented May 18, 2022

PPDSC-2117

Note 🚨: If the Tooltip is wrapping a functional component, the functional component needs to accept a ref using forwardRef.

I have done:

  • Written unit tests against changes
  • Written functional tests against the component and/or NewsKit site
  • Updated relevant documentation

I have tested manually:

  • The feature's functionality is working as expected on Chrome, Firefox, Safari and Edge
  • The screen reader reads and flows through the elements as expected.
  • There are no new errors in the browser console coming from this PR.
  • When visual test is not added, it renders correctly on different browsers and mobile viewports (Safari, Firefox, small mobile viewport, tablet)
  • The Playground feature is working as expected

Before:

After:

Who should review this PR:

How to test:

@github-actions github-actions bot added the feature This change contains a new feature label May 18, 2022
@Xin00163 Xin00163 added the ready for review Please assist in getting this reviewed label May 18, 2022
@Xin00163 Xin00163 added the ready for design review Please assist in getting this reviewed label May 18, 2022
Copy link
Contributor Author

@Xin00163 Xin00163 left a 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?

Copy link
Contributor

@mutebg mutebg left a 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 💯

src/icon-button/icon-button.tsx Show resolved Hide resolved
src/tooltip/types.ts Outdated Show resolved Hide resolved
src/tooltip/types.ts Outdated Show resolved Hide resolved
src/tooltip/styled.tsx Outdated Show resolved Hide resolved
src/tooltip/tooltip.tsx Outdated Show resolved Hide resolved
src/tooltip/tooltip.tsx Outdated Show resolved Hide resolved
return <Button {...props} size={size} overrides={iconButtonSettings} />;
};
return (
<Button {...props} size={size} ref={ref} overrides={iconButtonSettings} />
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Definitely

src/tooltip/types.ts Outdated Show resolved Hide resolved
src/tooltip/tooltip.tsx Outdated Show resolved Hide resolved
@Xin00163 Xin00163 removed the ready for design review Please assist in getting this reviewed label May 20, 2022
mstuartf
mstuartf previously approved these changes May 23, 2022
overrides,
...props
}) => {
const [open, setOpenState] = useControlled({
Copy link
Contributor

@Vanals Vanals May 23, 2022

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 🤔 ?

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 guess it's more concise

Copy link
Contributor

@Vanals Vanals May 23, 2022

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]

Comment on lines 52 to 54
// 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();
Copy link
Contributor

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 👍

Copy link
Contributor Author

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

Copy link
Contributor

@Vanals Vanals May 24, 2022

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?

Copy link
Contributor Author

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.

@Vanals
Copy link
Contributor

Vanals commented May 23, 2022

Looks good, just shared with you that issue with aria-label. Worth ticking the checkboxes once done, especially the one about Screen Readers! 😬
You can also test on NVDA with Assistive Labs

@Xin00163 Xin00163 requested review from Vanals and mstuartf May 24, 2022 09:31
@Xin00163
Copy link
Contributor Author

Looks good, just shared with you that issue with aria-label. Worth ticking the checkboxes once done, especially the one about Screen Readers! 😬 You can also test on NVDA with Assistive Labs

So as a result, we will need to make aria-label optional in Icon Button, otherwise we can't match the aria-label with the tooltip title.

@@ -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';
Copy link
Contributor

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 👍

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 don't mind. I did see childrenIsString and testSvgCodeIsString so don't think we are following this convention

Copy link
Contributor

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;
Copy link
Contributor

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 Show resolved Hide resolved
Comment on lines 65 to 66
labelOrDescProps['aria-label'] = titleIsString ? title : null;
labelOrDescProps['aria-labelledby'] = open && !titleIsString ? id : null;
Copy link
Contributor

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

Copy link
Contributor Author

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

@Vanals
Copy link
Contributor

Vanals commented May 24, 2022

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.

Vanals
Vanals previously approved these changes May 24, 2022
src/tooltip/tooltip.tsx Show resolved Hide resolved
src/tooltip/tooltip.tsx Outdated Show resolved Hide resolved
@@ -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';
Copy link
Contributor

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 👍

tbradbury
tbradbury previously approved these changes May 24, 2022
@Xin00163 Xin00163 dismissed stale reviews from tbradbury and Vanals via 92c2236 May 24, 2022 11:09
@Xin00163 Xin00163 merged commit 573f35a into main May 25, 2022
@Xin00163 Xin00163 deleted the feat/PPDSC-2117-tooltip-panel-and-content branch May 25, 2022 09:45
Xin00163 added a commit that referenced this pull request Oct 17, 2022
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This change contains a new feature ready for review Please assist in getting this reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants