Skip to content

fix(editor): hide floating toolbar when switching notes#401

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
Resurgamz:feature/fix-BUG365817
Jul 8, 2026
Merged

fix(editor): hide floating toolbar when switching notes#401
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
Resurgamz:feature/fix-BUG365817

Conversation

@Resurgamz

@Resurgamz Resurgamz commented Jul 8, 2026

Copy link
Copy Markdown

fix(editor): hide floating toolbar when switching notes

Hide the editor floating toolbar unconditionally when note data changes.
切换笔记内容时无条件隐藏编辑区悬浮工具栏。
Also clear font and font-size dropdown open states when hiding air popover
隐藏气泡工具栏时同步清理字体和字号下拉展开状态。

Log:修复切换笔记后字体气泡工具栏残留
Bug: https://pms.uniontech.com/bug-view-365817.html
Influence:修复展开字体下拉栏后切换笔记时悬浮气泡工具栏未消失的问题。

@sourcery-ai

sourcery-ai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR ensures the rich text editor’s floating toolbar (Summernote air popover) is always hidden and fully reset when switching notes or hiding the popover, preventing residual open dropdown states for font and font size.

Sequence diagram for hiding editor air popover when switching notes

sequenceDiagram
    actor User
    participant WebRichTextEditor
    participant JsContent
    participant AirPopover

    User->>WebRichTextEditor: setData(data, reg)
    WebRichTextEditor->>JsContent: callJsHideEditToolbar()
    JsContent->>AirPopover: hide()
    AirPopover-->>JsContent: popover hidden
    JsContent-->>WebRichTextEditor: toolbar hidden
Loading

File-Level Changes

Change Details Files
Always hide the editor floating toolbar when switching notes, regardless of focus state.
  • Removed the focus check before hiding the edit toolbar in the note data setter
  • Now unconditionally emits the JavaScript call to hide the edit toolbar at the beginning of note switching logic
src/views/webrichtexteditor.cpp
Reset font-related dropdown open state when hiding the Summernote air popover.
  • On air popover hide, clear the open state of the color dropdown
  • Also clear the open state of the font size dropdown
  • Also clear the open state of the font family dropdown before hiding the popover
assets/web/js/summernote_v9_2.js

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
  • 敏感词检查失败, 检测到1个文件存在敏感词
详情
{
    "assets/web/js/summernote_v9_2.js": [
        {
            "line": "    var KEY_BOGUS = 'bogus';",
            "line_number": 3943,
            "rule": "S106",
            "reason": "Var naming | 6d7db7168d"
        },
        {
            "line": "                    .attr('src', 'https://instagram.com/p/' + igMatch[1] + '/embed/')",
            "line_number": 6957,
            "rule": "S35",
            "reason": "Url link | dcb31e9ddf"
        },
        {
            "line": "                    .attr('src', 'http://v.qq.com/iframe/player.html?vid=' + vid + '&auto=0');",
            "line_number": 6994,
            "rule": "S35",
            "reason": "Url link | ce631f8419"
        }
    ]
}

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Hide the editor floating toolbar unconditionally when note data changes.

切换笔记内容时无条件隐藏编辑区悬浮工具栏。

Also clear font and font-size dropdown open states when hiding air popover.

隐藏气泡工具栏时同步清理字体和字号下拉展开状态。

Log: 修复切换笔记后字体气泡工具栏残留

Bug: https://pms.uniontech.com/bug-view-365817.html

Influence: 修复展开字体下拉栏后切换笔记时悬浮气泡工具栏未消失的问题。
@Resurgamz
Resurgamz force-pushed the feature/fix-BUG365817 branch from ed2a560 to 071bbc5 Compare July 8, 2026 06:37
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
  • 敏感词检查失败, 检测到1个文件存在敏感词
详情
{
    "assets/web/js/summernote_v9_2.js": [
        {
            "line": "    var KEY_BOGUS = 'bogus';",
            "line_number": 3943,
            "rule": "S106",
            "reason": "Var naming | 6d7db7168d"
        },
        {
            "line": "                    .attr('src', 'https://instagram.com/p/' + igMatch[1] + '/embed/')",
            "line_number": 6957,
            "rule": "S35",
            "reason": "Url link | dcb31e9ddf"
        },
        {
            "line": "                    .attr('src', 'http://v.qq.com/iframe/player.html?vid=' + vid + '&auto=0');",
            "line_number": 6994,
            "rule": "S35",
            "reason": "Url link | ce631f8419"
        }
    ]
}

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:100分

■ 【总体评价】

代码精准修复了富文本编辑器切换笔记时的UI状态残留问题。
逻辑严密且无任何副作用,符合满分标准。

■ 【详细分析】

  • 1.语法逻辑(完全正确)✓
    JS端在AirPopover.prototype.hide中补充了遗漏的类移除操作,C++端在WebRichTextEditor::setData中移除了不合理的hasFocus()限制条件,双向修复彻底解决了状态残留的根因。
    建议:无需改进。
  • 2.代码质量(良好)✓
    修改后的注释“切换笔记时隐藏编辑工具栏,避免下拉状态残留”准确描述了业务意图,代码风格与上下文保持一致。
    建议:无需改进。
  • 3.代码性能(无性能问题)✓
    新增的两次jQuery类名移除操作仅针对特定元素,开销可忽略不计;C++端去除了条件判断,执行路径更加直接。
    建议:无需改进。
  • 4.代码安全(存在0个安全漏洞)✓
    漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
    本次修改仅涉及前端UI状态清理和Qt信号触发,未引入任何新的安全风险。
    建议:无需改进。

■ 【改进建议代码示例】

diff --git a/src/views/webrichtexteditor.cpp b/src/views/webrichtexteditor.cpp
index f113d651..cea9c5aa 100644
--- a/src/views/webrichtexteditor.cpp
+++ b/src/views/webrichtexteditor.cpp
@@ -741,10 +741,8 @@ void WebRichTextEditor::onLoadFinsh()
 
 void WebRichTextEditor::setData(VNoteItem *data, const QString &reg)
 {
-    //有焦点先隐藏编辑工具栏
-    if (hasFocus()) {
-        emit JsContent::instance()->callJsHideEditToolbar();
-    }
+    //切换笔记时隐藏编辑工具栏,避免下拉状态残留
+    emit JsContent::instance()->callJsHideEditToolbar();
 
     if (nullptr == data) {
         this->setVisible(false);

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: max-lvs, Resurgamz

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@Resurgamz

Copy link
Copy Markdown
Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

This pr force merged! (status: unstable)

@deepin-bot
deepin-bot Bot merged commit b1d5da6 into linuxdeepin:master Jul 8, 2026
21 of 23 checks passed
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.

3 participants