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

chore: Replace removeEventListener with abort controller #3206

Merged
merged 3 commits into from
Jan 21, 2025

Conversation

georgylobko
Copy link
Contributor

@georgylobko georgylobko commented Jan 20, 2025

Description

Replaced removeEventListener with AbortController.abort where it brought code clarify, specifically when multiple event listeners should be removed at once.

Dry-run: 7201850483

The AbortController is supported in jest from version 27. For those who use older versions (if any), should either update their jest or use a workaround, for instance, this one: facebook/create-react-app#11626 (comment)

Related links, issue #, if available: n/a

How has this been tested?

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.

@@ -93,7 +93,7 @@ export function animate({
if (event.target === element) {
// Clean up remaining inline styles
element.style.transitionProperty = '';
element.removeEventListener('transitionstart', onTransitionEnd);
element.removeEventListener('transitionend', onTransitionEnd);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change does not have to do anything with AbortController, I just noticed this typo

Copy link

codecov bot commented Jan 20, 2025

Codecov Report

Attention: Patch coverage is 96.72131% with 2 lines in your changes missing coverage. Please review.

Project coverage is 96.42%. Comparing base (f5a88e4) to head (8c7b9a1).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/internal/animate.ts 0.00% 1 Missing ⚠️
src/internal/components/transition/index.tsx 75.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main    #3206    +/-   ##
========================================
  Coverage   96.42%   96.42%            
========================================
  Files         787      787            
  Lines       22195    22191     -4     
  Branches     7209     7614   +405     
========================================
- Hits        21401    21398     -3     
+ Misses        787      786     -1     
  Partials        7        7            

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

…ts listeners are attached to specific instances
@georgylobko georgylobko marked this pull request as ready for review January 20, 2025 17:16
@georgylobko georgylobko requested a review from a team as a code owner January 20, 2025 17:16
@georgylobko georgylobko requested review from cansuaa and removed request for a team January 20, 2025 17:16
jest.spyOn(tableRef.current!, 'removeEventListener').mockImplementation(rootRemoveEventListener as any);
abortFn();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see AbortController being used in table/use-table-focus-navigation.ts so the test shouldn't be changed. And it's very normal that the related test is passing because basically here you are directly calling the function and asserting that it is called below in the test. So even abort was used in the file, I don't think these two lines are really testing the same thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I initially introduced AbortController in the table/use-table-focus-navigation.ts, but then decided to get rid of it, because it didn't bring any benefit there. Addressed

@georgylobko georgylobko added this pull request to the merge queue Jan 21, 2025
Merged via the queue into main with commit 40e080c Jan 21, 2025
38 checks passed
@georgylobko georgylobko deleted the chore/abort-controller branch January 21, 2025 13:39
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.

2 participants