airbnb / lunar

🌗 React toolkit and design language for Airbnb open source and internal projects.
MIT License
464 stars 77 forks source link

update(Tooltip): Render Popover's popup in Overlay component #392

Closed espressoroaster closed 4 years ago

espressoroaster commented 4 years ago

to: @williaster @alecklandgraf

Description

This PR refactors Popover to render inside an <Overlay> component, just like the plain tooltip. It also moves the popup mouseEnter and mouseLeave handlers up to the popup content's outermost div.

Note: We'll want to land #391 first, and then update the target of this PR to master. I set the base of this PR to the Overlay PR to facilitate code review.

Motivation and Context

The original Popover component rendered in a simple div with a style of zIndex:1. This was naive on my part for several reasons:

  1. The Popover would need a much larger zIndex to escape divs with zIndexes potentially much larger than 1.
  2. In our Popover-inside-DataTable use case, the Popover was unable to escape a DataTable row, while a regular Tooltip, which rendered in Overlay's portal, was able to.

Testing

Tested with existing unit tests and new story book story.

Screenshots

popover-overlay-works

Checklist

airbnb-bot commented 4 years ago

Size Changes

Package Diff ESM Prev ESM CJS Prev CJS
core +0.0% 566.78 KB 566.56 KB 708.84 KB 708.61 KB

Compared to master. File sizes are unminified and ungzipped.

View raw build stats

Previous (master)

{
  "apollo": {
    "esm": 10832,
    "lib": 14147
  },
  "app-shell": {
    "esm": 12906,
    "lib": 19874
  },
  "composer": {
    "esm": 68247,
    "lib": 101805
  },
  "core": {
    "esm": 580157,
    "lib": 725612
  },
  "forms": {
    "esm": 37350,
    "lib": 49298
  },
  "icons": {
    "esm": 156355,
    "lib": 205626
  },
  "layouts": {
    "esm": 15298,
    "lib": 20770
  },
  "metrics": {
    "esm": 5467,
    "lib": 7729
  },
  "test-utils": {
    "esm": 4279,
    "lib": 5937
  }
}

Current

{
  "apollo": {
    "esm": 10832,
    "lib": 14147
  },
  "app-shell": {
    "esm": 12906,
    "lib": 19874
  },
  "composer": {
    "esm": 68247,
    "lib": 101805
  },
  "core": {
    "esm": 580380,
    "lib": 725857
  },
  "forms": {
    "esm": 37350,
    "lib": 49298
  },
  "icons": {
    "esm": 156355,
    "lib": 205626
  },
  "layouts": {
    "esm": 15298,
    "lib": 20770
  },
  "metrics": {
    "esm": 5467,
    "lib": 7729
  },
  "test-utils": {
    "esm": 4279,
    "lib": 5937
  }
}