Open tomekancu opened 6 months ago
We don't really support browsers that old, FF 68 was July 2019. Some of this code is from a time when we supported those older ones, but I don't think that is reason enough to add more support. Is there a current one (less than ~3 years old) which is displaying the problem?
You can work around it the same way we have in our components https://github.com/adobe/react-spectrum/blob/f6a664ba900c3e6307a0f9461241aa3b2397efeb/packages/%40react-spectrum/actiongroup/src/ActionGroup.tsx#L180
Provide a general summary of the issue here
If
useResizeObserver
is used on current browsers,onResize
is fired on first use. For older browsers that don't supportResizeObserver
, it is fired after the first resize of the browser window.π€ Expected Behavior?
onResize
is triggered on first renderπ― Current Behavior
onResize
is not triggered on first use as in supported browsersπ Possible Solution
We should call
onResize
in useEffect for an unsupported browser condition. https://github.com/adobe/react-spectrum/blob/f6a664ba900c3e6307a0f9461241aa3b2397efeb/packages/%40react-aria/utils/src/useResizeObserver.ts#L21-L26π¦ Context
The original
ResizeObserver
is called on theobserve
method. For the mock implementation with theresize
event, we do not have this behaviour. The firstonResize
must be called manually.π₯οΈ Steps to Reproduce
Codesandbox with "simulated" old browser by setting
window.ResizeObserver = undefined
https://codesandbox.io/p/sandbox/useresizeobserver-not-triggered-on-init-hx3mkm or use the hook in older browsers like Firefox 68.0Version
1.1.1
What browsers are you seeing the problem on?
Firefox
If other, please specify.
No response
What operating system are you using?
Mac
π§’ Your Company/Team
No response
π· Tracking Issue
No response