feat: resolve the issue of the close button continuously displaying after enlarging the image#459
feat: resolve the issue of the close button continuously displaying after enlarging the image#459wuyiping0628 wants to merge 1 commit intodevfrom
Conversation
…fter enlarging the image
WalkthroughThe preview modal's close button is refactored from a locally-scoped variable to a persistent class field, enabling explicit visibility management ( Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip You can validate your CodeRabbit configuration file in your editor.If your editor has YAML language server, you can enable auto-completion and validation by adding |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/fluent-editor/src/modules/custom-image/preview/preview-modal.ts (1)
68-86: Consider usingtextContentinstead ofinnerHTML.While the hardcoded
×character isn't a security risk, usingtextContentis a safer pattern and avoids static analysis warnings.🔧 Proposed fix
this.closeBtn = document.createElement('button') this.closeBtn.className = 'tiny-editor-image-preview-close' - this.closeBtn.innerHTML = '×' + this.closeBtn.textContent = '×' this.closeBtn.style.cssText = `🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/fluent-editor/src/modules/custom-image/preview/preview-modal.ts` around lines 68 - 86, Replace the use of innerHTML on the modal close button with textContent to avoid unnecessary HTML parsing/static analysis warnings: locate the this.closeBtn setup in preview-modal.ts where the button is created (references: this.closeBtn, class 'tiny-editor-image-preview-close') and change this.closeBtn.innerHTML = '×' to use this.closeBtn.textContent = '×'; keep the rest of the setup and the click handler (this.hide()) unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/fluent-editor/src/modules/custom-image/preview/preview-modal.ts`:
- Around line 230-232: The destroy() method currently nulls instance fields but
does not reset the singleton reference, leaving globalPreviewModal pointing to a
dead instance; update destroy() in the PreviewModal class (the instance returned
by getImagePreviewModal()) to also set the module-level globalPreviewModal
variable to null so subsequent calls to getImagePreviewModal() create a fresh,
usable instance and avoid show() returning early on a destroyed object.
---
Nitpick comments:
In `@packages/fluent-editor/src/modules/custom-image/preview/preview-modal.ts`:
- Around line 68-86: Replace the use of innerHTML on the modal close button with
textContent to avoid unnecessary HTML parsing/static analysis warnings: locate
the this.closeBtn setup in preview-modal.ts where the button is created
(references: this.closeBtn, class 'tiny-editor-image-preview-close') and change
this.closeBtn.innerHTML = '×' to use this.closeBtn.textContent = '×'; keep the
rest of the setup and the click handler (this.hide()) unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e0b702aa-9bec-4e56-8f08-fcd3b7032e34
📒 Files selected for processing (1)
packages/fluent-editor/src/modules/custom-image/preview/preview-modal.ts
…fter enlarging the image
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #452
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit