fix(Markdown):修复关闭编辑弹窗时销毁的问题 - #1092
Open
Tony-ST0754 wants to merge 2 commits into
Open
Conversation
fix:修复Markdown组件在编辑弹窗中,关闭弹窗时浏览器控制台报错找不到节点元素的问题
|
Thanks for your PR, @Tony-ST0754. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideBinds the Markdown editor’s lifecycle to its containing Bootstrap modal so that the editor is disposed safely when the modal closes, preventing console errors about missing DOM nodes. Sequence diagram for Markdown editor disposal bound to Bootstrap modal lifecyclesequenceDiagram
actor User
participant BootstrapModal as BootstrapModal
participant MarkdownEditor as MarkdownEditor
participant Data as DataStore
User->>BootstrapModal: close()
BootstrapModal-->>BootstrapModal: emit hide.bs.modal
BootstrapModal->>MarkdownEditor: md._modalHideHandler()
MarkdownEditor->>MarkdownEditor: disposeEditor(id)
MarkdownEditor->>Data: Data.get(id)
MarkdownEditor->>BootstrapModal: md._modal.removeEventListener(hide.bs.modal, md._modalHideHandler)
MarkdownEditor->>Data: Data.remove(id)
MarkdownEditor->>MarkdownEditor: md._editor.off(blur)
MarkdownEditor->>MarkdownEditor: md._editor.destroy()
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- disposeEditor assumes Data.get(id) returns a valid object; consider adding null/undefined guards around md and md._editor to avoid errors if dispose is called multiple times (e.g., both from the modal hide handler and the component lifecycle).
- The modal event listener is attached to 'hide.bs.modal', which fires before the modal is fully hidden; verify whether binding to 'hidden.bs.modal' would better align with the timing of DOM removal and avoid potential race conditions with other modal teardown logic.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- disposeEditor assumes Data.get(id) returns a valid object; consider adding null/undefined guards around md and md._editor to avoid errors if dispose is called multiple times (e.g., both from the modal hide handler and the component lifecycle).
- The modal event listener is attached to 'hide.bs.modal', which fires before the modal is fully hidden; verify whether binding to 'hidden.bs.modal' would better align with the timing of DOM removal and avoid potential race conditions with other modal teardown logic.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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.
fix:修复Markdown组件在编辑弹窗中,关闭弹窗时浏览器控制台报错找不到节点元素的问题
Link issues
fixes #1091
问题描述 / Problem Description
当组件在弹窗中使用时,由于弹窗先销毁,然后再销毁组件,导致组件在销毁时找不到对应的元素
解决方案 / Solution
在组件初始化时,将组件的销毁与弹窗的销毁绑定
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Bug Fixes: