Skip to content

Conversation

@beefchimi
Copy link
Contributor

This PR replaces the previous effort: #4303

We are now always observing the Overlay attributes. We feel that the performance cost will not be that severe, and it is better to take this first step than to introduce another prop to the API.

Our main ask here is having control over how the Popover re-renders (re-sizes/positions itself). Eventually, we think a better solution is to offer a mechanism to force a re-render. In the words of @clauderic

...the best way to support consumers that have complex use-cases would be to add an imperative API to force the popover to be re-measured from the consumer, something like:

function ConsumerComponent() {
  const popoverRef = useRef();

  return (
    <>
      <Button onClick={forceMeasurePopover}>Click me</Button>
      <Popover ref={popoverRef} />
    </>
  );

  function forceMeasurePopover() {
    popoverRef.currrent.forceUpdateMeasurement();
  }
}

@github-actions
Copy link
Contributor

github-actions bot commented Aug 9, 2021

size-limit report

Path Size
cjs 142.56 KB (+0.03% 🔺)
esm 96.31 KB (+0.01% 🔺)
esnext 139.51 KB (+0.01% 🔺)
css 33.75 KB (0%)

Copy link
Member

@kyledurand kyledurand left a comment

Choose a reason for hiding this comment

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

Love this approach and that we don't have to add another nested prop to popover 👍

Thanks @beefchimi

mutationObserverObserveSpy.mockRestore();
});

it('observers the overlay', () => {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
it('observers the overlay', () => {
it('observes the overlay', () => {

Copy link
Member

@AndrewMusgrave AndrewMusgrave left a comment

Choose a reason for hiding this comment

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

LGTM! ✅

@beefchimi beefchimi force-pushed the popover-observe-attributes branch 2 times, most recently from 4174186 to c2c2ac1 Compare August 10, 2021 15:18
@beefchimi
Copy link
Contributor Author

Closed in favour of: #4385

@beefchimi beefchimi closed this Aug 19, 2021
@beefchimi beefchimi deleted the popover-observe-attributes branch August 19, 2021 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants