Skip to content

Conversation

lxfu1
Copy link
Member

@lxfu1 lxfu1 commented Sep 26, 2025

Description

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Enhancement (changes that improvement of current feature or performance)
  • Refactoring (changes that neither fixes a bug nor adds a feature)
  • Test Case (changes that add missing tests or correct existing tests)
  • Code style optimization (changes that do not affect the meaning of the code)
  • Docs (changes that only update documentation)
  • Chore (changes that don't modify src or test files)

Self Check before Merge

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Copy link
Contributor

Summary of Changes

Hello @lxfu1, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a bug where text entered into the edge editor might not be correctly saved or could become invalid under certain conditions, such as when interacting with arrowheads. The changes ensure that any modifications made within the cell editor are reliably captured and the editor is properly dismissed, whether the user clicks outside of it or simply moves their mouse away.

Highlights

  • Bug Fix: Addresses an issue where edge editor text could become invalid, particularly when configuring arrowheads, by ensuring changes are saved correctly.
  • Improved Editor Behavior: The cell editor now listens for mouseleave events, automatically saving the text and dismissing the editor when the mouse pointer moves out of its area.
  • Code Refactoring: Extracted the logic for saving editor content and removing the editor into a new updateCell method, improving code reusability and maintainability.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses an issue where text in the edge editor could be lost when configuring an arrowhead. The fix introduces a mouseleave event handler on the editor, ensuring that content is saved when the mouse moves away. This change is well-implemented and includes a good refactoring that extracts the cell update logic into a new updateCell method. This new method is used by both the new mouseleave handler and the existing mouseup handler, which improves code clarity and reduces duplication. My review includes a suggestion to add a null check in the new updateCell method to make it more robust and self-contained.

Comment on lines +178 to +184
updateCell() {
const value = this.editor.innerText.replace(/\n$/, '') || ''
// set value, when value is null, we will remove label in edge
this.setCellText(value !== '' ? value : null)
// remove tool
this.removeElement()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For better robustness and to make updateCell self-contained, it's a good practice to add a null check for this.editor at the beginning of the method. Although the current callers of updateCell already perform this check, adding it here will prevent potential null reference errors if the method is called from other places in the future without a check.

  updateCell() {
    if (!this.editor) {
      return
    }
    const value = this.editor.innerText.replace(/\n$/, '') || ''
    // set value, when value is null, we will remove label in edge
    this.setCellText(value !== '' ? value : null)
    // remove tool
    this.removeElement()
  }

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 20.00000% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.04%. Comparing base (d1f0fd1) to head (69f21f1).

Files with missing lines Patch % Lines
src/registry/tool/editor.ts 20.00% 8 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4801      +/-   ##
==========================================
- Coverage   82.05%   82.04%   -0.01%     
==========================================
  Files         327      327              
  Lines       37658    37665       +7     
  Branches     7597     7597              
==========================================
+ Hits        30900    30902       +2     
- Misses       6734     6739       +5     
  Partials       24       24              
Flag Coverage Δ
x6 82.04% <20.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/registry/tool/editor.ts 15.71% <20.00%> (+0.32%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lxfu1 lxfu1 merged commit 863d569 into master Sep 29, 2025
2 checks passed
@lxfu1 lxfu1 deleted the fix/edge-editor-text-invalid branch September 29, 2025 02:55
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.

边上工具添加source-arrowhead后,导致鼠标移出的时边的label值无法保存
3 participants