Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Cache dropdown's overflow parents for better jsdom performance #1669

Closed
wants to merge 3 commits into from

Conversation

jperals
Copy link
Member

@jperals jperals commented Oct 18, 2023

Description

getOverflowParents is expensive on testing environments because we are calling getComputedStyle on every element in the parent chain and Jest does not yet incorporate a version of jsdom that includes this fix. This causes some packages to have test timeouts after #1555.

This PR handles this by caching the result of getOverflowParents in the dropdown component. Note that it does not cache their dimensions, which will still be recalculated as necessary.

Ticket: AWSUI-22613

How has this been tested?

  • Successful dry-run build to previously failing package
  • Successfully ran tests in previously failing package, and observed that the run time is reduced significantly (~3x).
Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

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

@codecov
Copy link

codecov bot commented Oct 18, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (9369a80) 94.19% compared to head (5cfd326) 94.19%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1669      +/-   ##
==========================================
- Coverage   94.19%   94.19%   -0.01%     
==========================================
  Files         650      650              
  Lines       17523    17531       +8     
  Branches     5769     5772       +3     
==========================================
+ Hits        16506    16513       +7     
- Misses        948      949       +1     
  Partials       69       69              
Files Coverage Δ
...ternal/components/dropdown/dropdown-fit-handler.ts 94.57% <100.00%> (ø)
src/internal/components/dropdown/index.tsx 91.81% <100.00%> (+0.50%) ⬆️
src/internal/utils/scrollable-containers.ts 88.46% <100.00%> (-0.83%) ⬇️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jperals jperals marked this pull request as ready for review October 18, 2023 13:32
@jperals jperals requested a review from a team as a code owner October 18, 2023 13:32
@jperals jperals requested review from michaeldowseza and removed request for a team October 18, 2023 13:32
@jperals
Copy link
Member Author

jperals commented Oct 20, 2023

Closing in favor of #1679

@jperals jperals closed this Oct 20, 2023
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