Skip to content

fix(frontend): suppress newline on Enter in title editors - #8055

Open
aglinxinyuan wants to merge 1 commit into
apache:mainfrom
aglinxinyuan:fix/title-editor-enter-newline
Open

fix(frontend): suppress newline on Enter in title editors#8055
aglinxinyuan wants to merge 1 commit into
apache:mainfrom
aglinxinyuan:fix/title-editor-enter-newline

Conversation

@aglinxinyuan

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

The operator and port title editors bind Enter to "commit and close" so that a
display name stays a single-line value. Since the move to Quill 2 (#6418) that
suppression has been dead: Enter inserted a literal newline into the shared
Y.Text, which is published to every co-editor and persisted with the workflow.

Root cause — Quill 2 resolves a keydown against two buckets, event.key first:

bindings[evt.key] ++ bindings[evt.which]   // "Enter" bucket, then 13 bucket
matches.some(handler)                      // first non-`true` return wins, loop stops

Quill's own handleEnter is registered under "Enter"; the editors registered
theirs under the legacy 13 keycode. So Quill's handler ran first, inserted the
newline, and short-circuited the loop before the editors' handler was reached.
The template's separate (keyup.enter) still closed the editor on key release,
so the rename looked like it worked.

Before:  Enter -> Quill handleEnter -> "\n" into shared text -> keyup closes editor
After:   Enter -> editor handler    -> commit and close, text untouched

Keying both bindings "Enter" puts them in the same bucket, registered ahead of
handleEnter (user options are added before Quill's built-ins).

Rename typed Enter pressed at Stored name before Stored name after
Sentiment Analysis end "Sentiment Analysis\n" "Sentiment Analysis"
Sentiment Analysis mid-word "Sen\ntiment Analysis" "Sentiment Analysis"
(untouched) start "\n" ""

No visual change: the editor renders identically before and after, which is why
this went unnoticed — the defect is only in the value that gets stored.

CollabWrapperComponent carries the same key: 13, but it is unreachable
(its call site is commented out) and #7351 deletes it, so it is left alone here.

Any related issues, documentation, discussions?

Closes #8053. Regression from #6418 (Quill 1 -> 2). Related: #7351.

How was this PR tested?

New regression tests in both title editors' specs mount the real Quill instance
and the real y-quill binding, open the editor through the template's edit button,
and press Enter as a keydown only — the template's (keyup.enter) fallback is
never dispatched, so it cannot mask a broken binding. Each asserts the shared
Y.Text and editingTitle. Coverage: caret at the end, mid-word, an empty name,
Shift+Enter, and an ordinary keystroke that must still reach the editor
(defaultPrevented === false, editor stays open).

The four positive tests fail on main and pass here; the negative one passes both
ways, as a control:

AssertionError: expected 'renamed\n' to be 'renamed'
AssertionError: expected 'ren\named' to be 'renamed'
AssertionError: expected '\n' to be ''
cd frontend && yarn install --frozen-lockfile
cd frontend && npx ng test --include "src/app/workspace/component/property-editor/**/*.spec.ts" --watch=false

316 passed | 1 skipped (317). Full frontend suite: 204 files, 5213 passed.
yarn build (production) succeeds. npx prettier --check and npx eslint clean.

jsdom has no layout engine, so Range#getBoundingClientRect is stubbed next to
the existing test-env polyfills — Quill calls it to place the caret and
quill-cursors calls it per remote cursor.

Manually verified in Chromium against Quill 2.0.3 with both binding forms side by
side and a real Enter keystroke: key: 13 stored "Sentiment Analysis\n" and left
the editor open; key: "Enter" stored "Sentiment Analysis" and closed it.

Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code, Opus 5

The operator and port title editors bind Enter to "commit and close" so a
display name stays single-line. Quill 2 buckets keyboard bindings by
`event.key` and registers its own `handleEnter` under "Enter", while the
editors registered theirs under the legacy `13` keycode. Quill's handler
therefore ran first and short-circuited the match loop, inserting a newline
into the shared Y.Text and never reaching the editors' handler. Only the
template's `(keyup.enter)` still closed the editor, so the rename looked
like it worked while a "\n" was published to every co-editor and persisted.

Key the bindings "Enter" so they resolve into the same bucket ahead of
`handleEnter`.

Regression tests mount the real editor and press Enter on keydown only, so
the template fallback cannot mask a broken binding; they cover a caret at
the end, mid-word, an empty name, Shift+Enter, and an ordinary keystroke
that must still reach the editor. jsdom has no layout engine, so
`Range#getBoundingClientRect` is stubbed alongside the existing test-env
polyfills — Quill calls it to place the caret.

Closes apache#8053
Copilot AI lite review requested due to automatic review settings August 27, 2026 20:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @mengw15, @carloea2, @Neilk1021
    You can notify them by mentioning @mengw15, @carloea2, @Neilk1021 in a comment.

@github-actions github-actions Bot added fix frontend Changes related to the frontend GUI labels Aug 27, 2026
@Yicong-Huang Yicong-Huang added the release/v1.2 back porting to release/v1.2 label Aug 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Backport auto-label report

This fix: PR was checked against each actively-supported release branch. release/* labels drive the post-merge backport, so add or remove one to change where this fix lands.

Release branch Analysis
release/v1.2 Change detected on this branch — label added; this fix is queued to backport here. Requested review from @xuang7.

Auto-label run.

@github-actions
github-actions Bot requested a review from xuang7 August 27, 2026 20:53
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.44%. Comparing base (b01b11f) to head (f2a4d19).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8055      +/-   ##
============================================
+ Coverage     93.41%   93.44%   +0.02%     
  Complexity     4696     4696              
============================================
  Files          1179     1179              
  Lines         47713    47713              
  Branches       5314     5314              
============================================
+ Hits          44573    44586      +13     
+ Misses         1698     1682      -16     
- Partials       1442     1445       +3     
Flag Coverage Δ *Carryforward flag
access-control-service 81.00% <ø> (ø) Carriedforward from b01b11f
agent-service 99.32% <ø> (ø) Carriedforward from b01b11f
amber 89.60% <ø> (ø) Carriedforward from b01b11f
computing-unit-managing-service 73.67% <ø> (ø) Carriedforward from b01b11f
config-service 86.73% <ø> (ø) Carriedforward from b01b11f
file-service 86.70% <ø> (ø) Carriedforward from b01b11f
frontend 95.96% <ø> (+0.06%) ⬆️
notebook-migration-service 79.31% <ø> (ø) Carriedforward from b01b11f
pyamber 97.78% <ø> (ø) Carriedforward from b01b11f
workflow-compiling-service 77.19% <ø> (ø) Carriedforward from b01b11f

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

fix frontend Changes related to the frontend GUI release/v1.2 back porting to release/v1.2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enter in an operator title editor saves a newline into the display name

4 participants