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-2120): popover v1 #228

Merged
merged 26 commits into from
Jun 22, 2022
Merged

feat(PPDSC-2120): popover v1 #228

merged 26 commits into from
Jun 22, 2022

Conversation

mstuartf
Copy link
Contributor

@mstuartf mstuartf commented Jun 10, 2022

PPDSC-2120

What

  1. Background: add Popover component
  2. Created BaseFloatingElement component to be used by Tooltip and Popover
  3. What does the reviewers should expect

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

Differences to ticket:

  • Removed support for defaultOpen prop for Tooltip and Popover due to issue with 3rd party lib
  • Added aria-labelledby to Popover floating element to prevent aria-dialog-name issue (also requires giving the reference element an id if it does not already have one).
  • overrides.distance must be a px string
  • Added a pointer.padding default / override so that the pointer does not reach the edge of the element (this looks strange with border radius applied).
  • Changed fallbackPlacement to fallbackBehaviour for clarity.

mstuartf added 2 commits June 8, 2022 16:32
- Add base component to support Tooltip and Popover
- Move offset utils and tests to base component folder
- Use base component for Tooltip
- Create Popover component using base component
- Add basic Popover tests and stories
@mstuartf mstuartf added the WIP Work in progress label Jun 10, 2022
@github-actions github-actions bot added the feature This change contains a new feature label Jun 10, 2022
@newskit-engineering
Copy link
Collaborator

mstuartf added 3 commits June 14, 2022 11:59
- Applying offset manually gives us more flexibility for overrides
- But this is not compatible with the flip() middleware
- Simplify distance override type (string) and use lib middleware
- Update tests
- Use flip() and shift() middlewares to keep floating element within parent boundary
- Add stories showcasing behaviour and for visual tests. Hard to test flip and shift in unit tests.
@mstuartf mstuartf force-pushed the feat/PPDSC-2120-popover-v1 branch from 7acfd7d to 74f8c06 Compare June 15, 2022 15:21
mstuartf added 6 commits June 16, 2022 08:49
- floating-ui/floating-ui#1741
- There is a bug in the lib that prevents setting to open by default in the uncontrolled case
- Remove support for this prop and update tests / stories
- Icon buttons in popover stories must have aria-label attr
- Only add aria-controls to the ref element if the popover is open
@mstuartf mstuartf added ready for review Please assist in getting this reviewed and removed WIP Work in progress labels Jun 16, 2022
src/popover/__tests__/popover.stories.tsx Outdated Show resolved Hide resolved
src/popover/__tests__/popover.stories.tsx Outdated Show resolved Hide resolved
src/tooltip/defaults.ts Outdated Show resolved Hide resolved
src/tooltip/types.ts Outdated Show resolved Hide resolved
src/tooltip/tooltip.tsx Show resolved Hide resolved
src/base-floating-element/utils.ts Outdated Show resolved Hide resolved
src/base-floating-element/utils.ts Show resolved Hide resolved
src/base-floating-element/base-floating-element.tsx Outdated Show resolved Hide resolved
@mutebg
Copy link
Contributor

mutebg commented Jun 17, 2022

few more things from the ticket:

  • its mention that Esc key shout close the popover
  • In the next ticket, we will need to add the Header, and Close button props, wondering if we should implement the Content component now since is part of that ticket, or leave it for later when we have the header and close btn

@mstuartf
Copy link
Contributor Author

mstuartf commented Jun 17, 2022

  • its mention that Esc key shout close the popover

I clarified this with Mike M and he said we should not do this. See comments on the ticket: https://nidigitalsolutions.jira.com/browse/PPDSC-2120

  • In the next ticket, we will need to add the Header, and Close button props, wondering if we should implement the Content component now since is part of that ticket, or leave it for later when we have the header and close btn

I'd rather not add any more to this PR if that's ok.

@mutebg

@mutebg
Copy link
Contributor

mutebg commented Jun 20, 2022

  • its mention that Esc key shout close the popover

I clarified this with Mike M and he said we should not do this. See comments on the ticket: https://nidigitalsolutions.jira.com/browse/PPDSC-2120

  • In the next ticket, we will need to add the Header, and Close button props, wondering if we should implement the Content component now since is part of that ticket, or leave it for later when we have the header and close btn

I'd rather not add any more to this PR if that's ok.

@mutebg

Thanks, I should have read the comments as well. Seems good

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.

Everything seems good to me, ready to approve it. just let me know when you fix your snapshots!

mutebg
mutebg previously approved these changes Jun 21, 2022
Copy link
Contributor

@tbradbury tbradbury left a comment

Choose a reason for hiding this comment

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

LGTM

@mstuartf mstuartf merged commit c9d7b7e into main Jun 22, 2022
@mstuartf mstuartf deleted the feat/PPDSC-2120-popover-v1 branch June 22, 2022 11:04
Xin00163 pushed a commit that referenced this pull request Oct 17, 2022
* feat(PPDSC-2120): mock useId to make tooltip tests less brittle

* feat(PPDSC-2120): popover v1

- Add base component to support Tooltip and Popover
- Move offset utils and tests to base component folder
- Use base component for Tooltip
- Create Popover component using base component
- Add basic Popover tests and stories

* feat(PPDSC-2120): use floating-ui offset middleware

- Applying offset manually gives us more flexibility for overrides
- But this is not compatible with the flip() middleware
- Simplify distance override type (string) and use lib middleware
- Update tests

* feat(PPDSC-2120): add support for arrow padding

* feat(PPDSC-2120): add flip and shift support

- Use flip() and shift() middlewares to keep floating element within parent boundary
- Add stories showcasing behaviour and for visual tests. Hard to test flip and shift in unit tests.

* feat(PPDSC-2120): remove support for default open

- floating-ui/floating-ui#1741
- There is a bug in the lib that prevents setting to open by default in the uncontrolled case
- Remove support for this prop and update tests / stories

* feat(PPDSC-2120): fix a11y errors

- Icon buttons in popover stories must have aria-label attr
- Only add aria-controls to the ref element if the popover is open

* feat(PPDSC-2120): fix aria-dialog-name issue

* feat(PPDSC-2120): fix firefox style overrides issue

* feat(PPDSC-2120): hide non-test stories from applitools

* feat(PPDSC-2120): remove duplicate content check from popover

* feat(PPDSC-2120): remove unneeded props from tooltip

* feat(PPDSC-2120): update pointer padding prop name

* feat(PPDSC-2120): simplify px override logic

* feat(PPDSC-2120): don't show warnings on prod

* feat(PPDSC-2120): rename positions to placements in stories

* feat(PPDSC-2120): update focus behaviour

- Focus shifts to panel (not entire Popover) on open. This is to prevent focus outline bugs on all browsers caused by the pointer rotation.

* feat(PPDSC-2120): allow pointer events inside popover

* feat(PPDSC-2120): implement design review feedback

* feat(PPDSC-2120): update theme snapshots

* feat(PPDSC-2120): fix a11y story contrast issue
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.

4 participants