Skip to content

Fix ImageEnlarger: accessibility, modal re-entry, responsive images, MutationObserver perf#925

Merged
PythonSmall-Q merged 5 commits intofeat/resize-picturefrom
copilot/sub-pr-924
Mar 7, 2026
Merged

Fix ImageEnlarger: accessibility, modal re-entry, responsive images, MutationObserver perf#925
PythonSmall-Q merged 5 commits intofeat/resize-picturefrom
copilot/sub-pr-924

Conversation

Copy link
Contributor

Copilot AI commented Mar 7, 2026

  • Analyze review comments and current code
  • Remove non-functional ::after pseudo-element CSS; add title tooltip instead
  • Change close button from <span> to <button> with aria-label for accessibility
  • Fix modal image exclusion with img.closest(".xmoj-image-modal")
  • Use img.currentSrc || img.src for responsive image support
  • Optimize MutationObserver to iterate only over newly added nodes
  • Fix close button white background: add background: none; border: none; padding: 0 to reset browser default <button> styles

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.


Summary by cubic

Adds a modal image viewer so users can enlarge images from thumbnails, addressing feedback in #924. Improves readability, accessibility, and performance on desktop and mobile.

  • New Features
    • Click an image to open a modal with a larger view (uses img.currentSrc || img.src for responsive/lazy images).
    • Close with Esc, overlay click, or the close button; focus returns to the trigger; background scroll is locked.
    • A11y/perf fixes: replace CSS tooltip with title="点击放大"; close button is a with aria-label/title and reset styles (no white background); ignore images inside the modal via closest(); MutationObserver applies only to newly added images.

Written for commit 259cc7a. Summary will update on new commits.

…rc, and MutationObserver performance

Co-authored-by: PythonSmall-Q <106425289+PythonSmall-Q@users.noreply.github.com>
@pull-request-size pull-request-size bot added size/M and removed size/XS labels Mar 7, 2026
Copilot AI changed the title [WIP] Add image enlarger feature with modal viewer Fix ImageEnlarger: accessibility, modal re-entry, responsive images, MutationObserver perf Mar 7, 2026
@PythonSmall-Q PythonSmall-Q marked this pull request as ready for review March 7, 2026 01:23
Copilot AI review requested due to automatic review settings March 7, 2026 01:23
@PythonSmall-Q
Copy link
Member

@copilot 右上角的×底色是白色,他的底色应该和弹出框其他部分相同

This comment was marked as outdated.

cubic-dev-ai[bot]

This comment was marked as off-topic.

Co-authored-by: PythonSmall-Q <106425289+PythonSmall-Q@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 7, 2026

@copilot 右上角的×底色是白色,他的底色应该和弹出框其他部分相同

已在 9b68c78 中修复。将 <span> 改为 <button> 时引入了浏览器默认的白色背景和边框,现在在 .xmoj-image-modal-close CSS 中添加了 background: none; border: none; padding: 0; line-height: 1 来重置这些默认样式,使关闭按钮的背景与弹出框其他部分保持一致(透明/暗色)。

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Shan Wenxiao <seanoj_noreply@yeah.net>
@hendragon-bot hendragon-bot bot added the user-script This issue or pull request is related to the main user script label Mar 7, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Shan Wenxiao <seanoj_noreply@yeah.net>
@PythonSmall-Q PythonSmall-Q merged commit 1d4a041 into feat/resize-picture Mar 7, 2026
2 of 3 checks passed
@PythonSmall-Q PythonSmall-Q deleted the copilot/sub-pr-924 branch March 7, 2026 01:35
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="XMOJ.user.js">

<violation number="1" location="XMOJ.user.js:5808">
P1: The modal opens a stale image URL because the click handler captures `effectiveSrc` at bind time instead of reading the current source at click time.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

});
img.addEventListener("click", (e) => {
e.stopPropagation();
OpenImageModal(effectiveSrc);
Copy link

@cubic-dev-ai cubic-dev-ai bot Mar 7, 2026

Choose a reason for hiding this comment

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

P1: The modal opens a stale image URL because the click handler captures effectiveSrc at bind time instead of reading the current source at click time.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At XMOJ.user.js, line 5808:

<comment>The modal opens a stale image URL because the click handler captures `effectiveSrc` at bind time instead of reading the current source at click time.</comment>

<file context>
@@ -5792,17 +5792,20 @@ int main()
                         img.addEventListener("click", (e) => {
                             e.stopPropagation();
-                            OpenImageModal(img.currentSrc || img.src);
+                            OpenImageModal(effectiveSrc);
                         });
                     }
</file context>
Suggested change
OpenImageModal(effectiveSrc);
OpenImageModal(img.currentSrc || img.src);
Fix with Cubic

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="XMOJ.user.js">

<violation number="1" location="XMOJ.user.js:5806">
P2: The modal opens a stale image URL because `effectiveSrc` is captured once instead of reading `img.currentSrc || img.src` when the image is clicked.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

img.title = "点击放大";
img.addEventListener("click", (e) => {
e.stopPropagation();
OpenImageModal(effectiveSrc);
Copy link

@cubic-dev-ai cubic-dev-ai bot Mar 7, 2026

Choose a reason for hiding this comment

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

P2: The modal opens a stale image URL because effectiveSrc is captured once instead of reading img.currentSrc || img.src when the image is clicked.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At XMOJ.user.js, line 5806:

<comment>The modal opens a stale image URL because `effectiveSrc` is captured once instead of reading `img.currentSrc || img.src` when the image is clicked.</comment>

<file context>
@@ -5792,17 +5792,18 @@ int main()
                         img.addEventListener("click", (e) => {
                             e.stopPropagation();
-                            OpenImageModal(img.currentSrc || img.src);
+                            OpenImageModal(effectiveSrc);
                         });
                     }
</file context>
Suggested change
OpenImageModal(effectiveSrc);
OpenImageModal(img.currentSrc || img.src || effectiveSrc);
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M user-script This issue or pull request is related to the main user script

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants