fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

usePopper: define boundaries with imperative handles

Open layershifter opened this issue 3 years ago • 7 comments
trafficstars

Describe the feature that you would like added

We need to allow define flipBoundary and overflowBoundary with imperative handles, similarly to setTarget.

function App() {
  const popperRef = React.useRef();
  const { targetRef, containerRef, arrowRef } = usePopper({
    popperRef
  });

  React.useEffect(() => {
    popperRef.setFlipBoundary(el);
  }, []);
}

Why?

Currently flipBoundary & overflowBoundary can be defined as elements only ➡️ this requires to use refs via React.useState():

function App() {
  const [flipBoundary, setFlipBoundary] = React.useState();

  return <div ref={setFlipBoundary} />;
}

This causes an additional re-render as such boundaries usually wrap a lot of components this results in performance issues. Using imperative handlers allows to avoid passing refs ➡️ additional re-renders.

What component or utility would this be added to

usePopper hook in @fluentui/react-positioning

layershifter avatar Jan 18 '22 13:01 layershifter

The issue was updated to propose extending existing imperative handle. With the previous proposal (functions) we cannot handle updates of refs properly.

layershifter avatar Mar 31 '22 09:03 layershifter

This has been northstar request, currently not blocking anybody.

miroslavstastny avatar Apr 06 '22 15:04 miroslavstastny

Because this issue has not had activity for over 150 days, we're automatically closing it for house-keeping purposes.

Still require assistance? Please, create a new issue with up-to date details.

msft-fluent-ui-bot avatar Sep 03 '22 16:09 msft-fluent-ui-bot

Because this issue has not had activity for over 150 days, we're automatically closing it for house-keeping purposes.

Still require assistance? Please, create a new issue with up-to date details.

msft-fluent-ui-bot avatar Feb 02 '23 10:02 msft-fluent-ui-bot

Because this issue has not had activity for over 150 days, we're automatically closing it for house-keeping purposes.

Still require assistance? Please, create a new issue with up-to date details.

msft-fluent-ui-bot avatar Jul 02 '23 13:07 msft-fluent-ui-bot

Because this issue has not had activity for over 150 days, we're automatically closing it for house-keeping purposes.

Still require assistance? Please, create a new issue with up-to date details.

Because this issue has not had activity for over 150 days, we're automatically closing it for house-keeping purposes.

Still require assistance? Please, create a new issue with up-to date details.