Skip to content

Alt Text form: add ignore class when fixing style_background_decorative - #1258

Open
monsterlag wants to merge 1 commit into
ucfopen:devfrom
monsterlag:fix/issue-1231-84bc
Open

monsterlag wants to merge 1 commit into
ucfopen:devfrom
monsterlag:fix/issue-1231-84bc

Conversation

@monsterlag

Copy link
Copy Markdown

Note

AI-generated, not reviewed by a human. This pull request was written by an AI coding agent and then checked by a separate AI review agent, which re-ran the tests described below. No human has reviewed the code. It is submitted by @monsterlag, who runs these agents. If that does not fit how you want to receive contributions, please feel free to close it.

Fixes #1231

What was wrong

The Equal Access style_background_decorative rule fails any element whose inline style has a CSS background with a url(...). It does not look at alt, title or role="presentation". So when the Alt Text form fixed one of these issues (for example by marking the background as decorative, which adds role="presentation" alt="" title=""), the next scan reported the same element again, indefinitely.

Fix

As suggested in the issue, when the Alt Text form is used on a style_background_decorative issue and the user picks "Add text" or "Mark as decorative", the form now also adds the udoit-ignore-style-background-decorative class (the issue's existing ignoreClass) to the element. Report.js already skips unresolved issues whose element carries udoit-ignore-[rule-id], so the issue no longer reappears after it has been fixed. If no option is selected the class is removed again. Other alt text rules are unchanged.

Changes are in assets/js/Components/Forms/AltTextForm.js, plus a new test, assets/js/__tests__/AltTextForm.test.js, that renders the form and checks the HTML it produces.

How tested

  • Added assets/js/__tests__/AltTextForm.test.js (4 tests). Before the change, the two tests that expect the ignore class failed (Tests: 2 failed, 2 passed). After it, all 4 pass.
  • The repository's Jest setup does not run as-is: jest-environment-jsdom is not a dependency (Jest 30 no longer bundles it), and jest.setup.js loads MSW, which throws ReferenceError: Response is not defined under jsdom. So I ran Jest with a temporary config outside the repo: the same testMatch and moduleNameMapper, jest-environment-jsdom@30 installed separately, and a setup file that loads only regenerator-runtime and @testing-library/jest-dom. Result: AltTextForm.test.js passed (4/4). The existing App.test.js still fails to load, with the same error before and after this change (SyntaxError: Cannot use import statement outside a module from @wavesurfer/react). That failure is unrelated to this PR.
  • npx eslint assets/js/Components/Forms/AltTextForm.js: the only errors are the two no-useless-escape errors that are already on dev, now on a different line number. On the new test file, eslint reports no-undef for the Jest globals (describe, it, expect, jest), as it does for the existing App.test.js, because the eslint config does not declare Jest globals.
  • npx encore production: compiled successfully.

I did not test this against a live LMS course or a real Equal Access scan.

…form

The Equal Access style_background_decorative rule flags any element with an
inline CSS background image, even after UDOIT marks it as decorative or adds
alt text, so the issue came back on every scan. When either option is chosen
for this rule, also add the udoit-ignore-style-background-decorative class so
the report skips the element afterwards.

Fixes ucfopen#1231

This branch has not been deployed

No deployments
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