Skip to content

Conversation

TrevorBurnham
Copy link

@TrevorBurnham TrevorBurnham commented Aug 24, 2025

All target browsers now support the native ResizeObserver API, making the polyfill unnecessary: https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver#browser_compatibility

This change reduces bundle size and simplifies the codebase.

Changes:

  • Remove @juggle/resize-observer dependency from package.json
  • Replace polyfill imports with native ResizeObserver API
  • Update useResizeObserver to use getBoundingClientRect() for initial sync measurement
  • Add convertElementToEntry() helper since native ResizeObserverEntry cannot be constructed
  • Remove mocks/@juggle/resize-observer.ts mock file
  • Add comprehensive Jest mocks for ResizeObserver and getBoundingClientRect in test environment
  • Extract ResizeObserver test mocks to separate reusable module

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

All target browsers now support native ResizeObserver API, making the
polyfill unnecessary. This change reduces bundle size and simplifies the
codebase.

Changes:
- Remove @juggle/resize-observer dependency from package.json
- Replace polyfill imports with native ResizeObserver API
- Update useResizeObserver to use getBoundingClientRect() for initial sync measurement
- Add convertElementToEntry() helper since native ResizeObserverEntry cannot be constructed
- Remove __mocks__/@juggle/resize-observer.ts mock file
- Add comprehensive Jest mocks for ResizeObserver and getBoundingClientRect in test environment
- Extract ResizeObserver test mocks to separate reusable module
@TrevorBurnham TrevorBurnham requested a review from a team as a code owner August 24, 2025 17:55
@TrevorBurnham TrevorBurnham requested review from patrixd and removed request for a team August 24, 2025 17:55
TrevorBurnham added a commit to TrevorBurnham/cloudscape-components that referenced this pull request Aug 24, 2025
All target browsers now support the native ResizeObserver API, making
the polyfill unnecessary.

This change reduces bundle size and simplifies the codebase.

Changes:
- Remove @juggle/resize-observer from package.json dependencies
- Update sticky scrollbar hook to use native ResizeObserver
- Add global ResizeObserver mock in Jest setup for JSDOM compatibility
- Update mock file to use native ResizeObserver types with JSDOM-compatible implementations

Note that the mock file can be removed once the polyfill is also removed
from @cloudscape-design/component-toolkit:
cloudscape-design/component-toolkit#154
@just-boris just-boris requested review from avinashbot and removed request for patrixd August 25, 2025 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant