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

Filter accessibility violations before unmounting #49

Merged
merged 1 commit into from
Oct 22, 2024

Conversation

robertknight
Copy link
Member

Change a potentially confusing behavior where components were unmounted before calling the shouldIgnoreViolation callback. Querying the rendered tree within the callback, eg. to get the ID of an element to check if a violation relates to it, could fail due to this.

Fixes #48.

Copy link
Contributor

@acelaya acelaya left a comment

Choose a reason for hiding this comment

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

Since we are now manipulating the list of reported violations directly in testScenario, I suggest we make that function return the new violations array instead of result.violations.


let violations = results.violations;
if (shouldIgnoreViolation) {
violations = violations.filter(v => !shouldIgnoreViolation(v));
Copy link
Contributor

@acelaya acelaya Oct 22, 2024

Choose a reason for hiding this comment

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

I suppose this may be working due to the overwriting of the violations reference, but perhaps we should make this function return violations instead of result.violations, otherwise it's not super obvious what this if statement does when overwriting the violations variable.

Copy link
Member Author

@robertknight robertknight Oct 22, 2024

Choose a reason for hiding this comment

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

Yes, the function should return the filtered violations. Otherwise the change doesn't work at all (!)

Copy link
Member Author

Choose a reason for hiding this comment

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

As an aside, we currently lack tests for this module which would have made this more obvious.

@acelaya
Copy link
Contributor

acelaya commented Oct 22, 2024

Change a potentially confusing behavior where components were unmounted before calling the shouldIgnoreViolation callback. Querying the rendered tree within the callback, eg. to get the ID of an element to check if a violation relates to it, could fail due to this.

I spend a few minutes yesterday trying to figure out why the IDs didn't match in hypothesis/client#6620 😅

This is a good catch.

Change a potentially confusing behavior where components were unmounted before
calling the `shouldIgnoreViolation` callback. Querying the rendered tree within
the callback, eg. to get the ID of an element to check if a violation relates to
it, could fail due to this.

Fixes #48.
@robertknight robertknight force-pushed the filter-violations-while-mounted branch from 83d1373 to 2197647 Compare October 22, 2024 09:45
@robertknight robertknight merged commit 1d6a232 into main Oct 22, 2024
2 checks passed
@robertknight robertknight deleted the filter-violations-while-mounted branch October 22, 2024 09:49
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.

Wrapper is unmounted when shouldIgnoreViolations is called
2 participants