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

[ARGG-1157][BpkTooltip]: Migrate tooltip to floating-ui #3485

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

olliecurtis
Copy link
Member

Migrating the underlying library of theBpkTooltip to use the maintainers replacement library floating-ui, a much more lightweight library and has a lot of functionality built in that means we can remove our use of custom built react Portals!

This is one PR of a few to update components away from popperjs to floating-ui so can be used as a base!

Changes here are as follows:

  • Removed TooltipPortal, as we no longer need to use our custom React Portal implementation as this is handled via floating-ui
  • Removed the renderTarget prop as this is longer needed to apply where in the DOM the tooltip should be and is located by floating-ui relative to the target
  • Removed the portalStyle and portalClassName as these are no longer required as we aren't using a custom portal
  • Removed the popperModifiers property as these no longer have an effect on the component
  • Removed className property to prevent overriding of component
  • Converted component to Typescript and generated types
  • Removed snapshot testing as this is unreliable and not best practice
  • Added visual testing

Migration guide:

The main changes for this component is removing properties that have minor to no impact to the current functionality of the component.

So remove use of the following properties: renderTarget, portalStyle, portalClassName, popperModifiers and className.

Should the design/style not be fit for purpose please align with design to make sure they use the component as expected before getting in touch.

Remember to include the following changes:

  • Ensure the PR title includes the name of the component you are changing so it's clear in the release notes for consumers of the changes in the version e.g [KOA-123][BpkButton] Updating the colour
  • README.md (If you have created a new component)
  • Component README.md
  • Tests
  • Storybook examples created/updated
  • For breaking changes or deprecating components/properties, migration guides added to the description of the PR. If the guide has large changes, consider creating a new Markdown page inside the component's docs folder and link it here

@olliecurtis olliecurtis added the major Breaking change label Jun 3, 2024
Copy link

github-actions bot commented Jun 3, 2024

Visit https://backpack.github.io/storybook-prs/3485 to see this build running in a browser.

Copy link

github-actions bot commented Jun 3, 2024

Visit https://backpack.github.io/storybook-prs/3485 to see this build running in a browser.

Copy link

github-actions bot commented Jun 3, 2024

Warnings
⚠️

Package source files (e.g. packages/package-name/src/Component.js) were updated, but snapshots weren't. Have you checked that the tests still pass?

⚠️

Package source files (e.g. packages/package-name/src/Component.tsx) were updated, but type files weren't. Have you checked that no types have changed?

Browser support

If this is a visual change, make sure you've tested it in multiple browsers.

Generated by 🚫 dangerJS against ea86aa3

Copy link

github-actions bot commented Jun 3, 2024

Visit https://backpack.github.io/storybook-prs/3485 to see this build running in a browser.

1 similar comment
Copy link

github-actions bot commented Jun 4, 2024

Visit https://backpack.github.io/storybook-prs/3485 to see this build running in a browser.

@olliecurtis olliecurtis force-pushed the ARGG-1157-tooltip-to-floating-ui branch from dbb5c17 to 35587fb Compare June 4, 2024 09:15
Copy link

github-actions bot commented Jun 4, 2024

Visit https://backpack.github.io/storybook-prs/3485 to see this build running in a browser.

@olliecurtis olliecurtis force-pushed the ARGG-1157-tooltip-to-floating-ui branch from 35587fb to 1b0b280 Compare June 4, 2024 12:53
Copy link

github-actions bot commented Jun 4, 2024

Visit https://backpack.github.io/storybook-prs/3485 to see this build running in a browser.

@olliecurtis olliecurtis force-pushed the ARGG-1157-tooltip-to-floating-ui branch from 1b0b280 to 6ec9e40 Compare June 4, 2024 14:36
Copy link

github-actions bot commented Jun 4, 2024

Visit https://backpack.github.io/storybook-prs/3485 to see this build running in a browser.

Copy link

github-actions bot commented Jun 4, 2024

Visit https://backpack.github.io/storybook-prs/3485 to see this build running in a browser.

Copy link

Visit https://backpack.github.io/storybook-prs/3485 to see this build running in a browser.

Copy link

Visit https://backpack.github.io/storybook-prs/3485 to see this build running in a browser.

*/
ariaLabel: string;
/**
* "target" should be a DOM element with a "ref" attached to it.
Copy link
Contributor

Choose a reason for hiding this comment

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

is that still the case?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes this is still the case, we will still want people to pass through a ReactElement and not a function like document.getElementById which is what the popover did, but the tooltip was never built to support that only

<div>
   My target
</div>

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean the ref part with a "ref" attached to it. . I see we're using floating ui to set the ref so I don't think the consumer has to? https://github.com/Skyscanner/backpack/pull/3485/files#diff-2702cb346943a8761bb30c82e1a61efeae40297ed8cee8028da4376b719dc73cR132-R138

Also interesting that you can clone an element and attach a ref to it 😮 I think that's new-ish, I think a few years ago it was not possible

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah gotcha! Let me do a test with removing that target ref and see what magic happens!

Also interesting that you can clone an element and attach a ref to it 😮 I think that's new-ish, I think a few years ago it was not possible

Interesting didn't realise it was a newer feature! I guess it is just a property to a DOM element so is easy to add this prop as any other?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah gotcha! Let me do a test with removing that target ref and see what magic happens!

Cool, have you checked that?

Interesting didn't realise it was a newer feature! I guess it is just a property to a DOM element so is easy to add this prop as any other?

Yeah, I remember it wasn't possible before, but not sure why 🤔

Copy link

Visit https://backpack.github.io/storybook-prs/3485 to see this build running in a browser.

Copy link

Visit https://backpack.github.io/storybook-prs/3485 to see this build running in a browser.

Copy link

Visit https://backpack.github.io/storybook-prs/3485 to see this build running in a browser.

@olliecurtis olliecurtis requested a review from anambl July 15, 2024 14:45
Copy link

Visit https://backpack.github.io/storybook-prs/3485 to see this build running in a browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
major Breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants