adobe / react-spectrum

A collection of libraries and tools that help you build adaptive, accessible, and robust user experiences.
https://react-spectrum.adobe.com
Apache License 2.0
12.8k stars 1.1k forks source link

Missing `updatePosition` from `usePopover` return value. #4040

Open tgelu opened 1 year ago

tgelu commented 1 year ago

๐Ÿ› Bug Report

usePopover is meant to replace the low-lever useOverlayPosition but because of a missing return value it can't in some cases.

๐Ÿค” Expected Behavior

updatePosition should be returned from usePopover.

๐Ÿ˜ฏ Current Behavior

updatePosition from useOverlayPosition which is useful for many scenarios, is not returned by usePopover.

๐Ÿ’ Possible Solution

There's an old, open PR.

๐Ÿ”ฆ Context

Was looking at replacing our usage of low-level hooks which have been replaced by usePopover.

๐Ÿ’ป Code Sample

N/A

๐ŸŒ Your Environment

N/A

๐Ÿงข Your Company/Team

N/A

๐Ÿ•ท Tracking Issue (optional)

N/A

devongovett commented 1 year ago

What are you using updatePosition for?

tgelu commented 1 year ago

In two places:

But I don't think we should focus too much on my use case. I guess it's only "coincidental" that I personally need updatePosition. I think the fact that updatePosition is returned from useOverlayPosition and the higher-level hook usePopover is meant to replace most, if not all, usages of useOverlayPosition it follows that updatePosition should also be returned from usePopover. Otherwise it is bound to still keep people on the lower-level hooks for various reasons (which may differ than the two examples above) and that defeats the purpose of usePopover for at least a chunk of react-aria users.

snow893 commented 1 year ago

@devongovett I could also really use this feature. We have a context menu which is tied to a field, and our designers want to be able to keep the menu open during a resize event. edit - triggering window resize event does the update but seems like an odd workaround @snowystinger cc