fix: frontend templates#211
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes the visibility detection in the “Images without ALT” toolbar audit by correctly treating any computed opacity value of 0 (including "0.0", "0.00", etc.) as hidden.
Changes:
- Replace a string comparison against
"0"with a numericparseFloat(...) !== 0check for computed opacity.
…proved performance
… scroll performance
Comment on lines
+86
to
+88
| menu.setAttribute("role", "dialog"); | ||
| menu.setAttribute("aria-modal", "true"); | ||
| menu.setAttribute("aria-label", "MageForge Toolbar"); |
Comment on lines
141
to
150
| function createOverlay(el, severity = "error") { | ||
| const overlay = document.createElement("span"); | ||
| overlay.className = AUDIT_OVERLAY_CLASS; | ||
| if (severity === "warning") | ||
| overlay.classList.add("mageforge-audit-overlay--warning"); | ||
| document.body.appendChild(overlay); | ||
|
|
||
| function update() { | ||
| if (!el.isConnected) { | ||
| cleanup(); | ||
|
|
||
| return; | ||
| } | ||
| // Set initial position synchronously so the overlay appears immediately. | ||
| if (el.isConnected) { | ||
| const rect = el.getBoundingClientRect(); |
Comment on lines
+192
to
216
| function repositionOverlay() { | ||
| if (!overlayState || !document.getElementById(OVERLAY_ID)) return; | ||
|
|
||
| const { sorted, badges, lines } = overlayState; | ||
|
|
||
| // --- Batched read phase --- | ||
| const rects = sorted.map((el) => el.getBoundingClientRect()); | ||
|
|
||
| // --- Batched write phase: badge positions --- | ||
| badges.forEach((badge, i) => { | ||
| badge.style.left = Math.round(rects[i].left + rects[i].width / 2) + "px"; | ||
| badge.style.top = Math.round(rects[i].top) + "px"; | ||
| }); | ||
|
|
||
| // --- Batched write phase: SVG line endpoints --- | ||
| lines.forEach((line, i) => { | ||
| line.setAttribute("x1", Math.round(rects[i].left + rects[i].width / 2)); | ||
| line.setAttribute("y1", Math.round(rects[i].top)); | ||
| line.setAttribute( | ||
| "x2", | ||
| Math.round(rects[i + 1].left + rects[i + 1].width / 2), | ||
| ); | ||
| line.setAttribute("y2", Math.round(rects[i + 1].top)); | ||
| }); | ||
| } |
Comment on lines
462
to
467
| * Set the inline counter badge of an audit menu item. | ||
| * | ||
| * @param {string} key | ||
| * @param {string} message | ||
| * @param {'success'|'error'} type | ||
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.