Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(editor): Fix save keybind in expression editor and unfocused node details view #13640

Merged

Conversation

Cadiac
Copy link
Contributor

@Cadiac Cadiac commented Mar 3, 2025

Summary

Cmd+S / Ctrl+S keybind to save the workflow at Node details view wasn't saving the workflow if NDV wasn't focused or if the expressions editor modal was open. This PR fixes that by registering a document level keydown capture listener while NDV is open, and unregistering it when closed.

Kapture.2025-03-03.at.15.04.50.mp4

When NDV is opened it isn't initially focused and as previously the listener was bound to the div so before clicking the NDV saving wouldn't work.

After focusing the NDV save would work, but if user then opened expression editor modal save keybind would again stop working. codemirror editor that opens would also register capture keydown handlers that would consume the events after handling them, and NDV's onKeyDown would never trigger. This has probably been broken since #12285 was merged.

SinceNDVFloatingNodes already registers a document level keydown capture listener I initially solved this at 7965627 by listening to save keybind there and emiting the event back up to NodeDetailsView, but I didn't like this solution as it left the @keydown.capture listener on NodeDetailsVIew that wasn't really doing what was expected.

My second and proposed solution is to register/unregister another document level keydown listener on NDV when the modal is opened or closed.

I'm still not convinced if this is the cleanest way to fix this, so feel free to give feedback or alternative ideas on how to fix this.

Related Linear tickets, Github issues, and Community forum posts

https://linear.app/n8n/issue/ADO-3120/bug-cmd-s-doesnt-save-when-in-expression-editor

Review / Merge checklist

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

@Cadiac Cadiac force-pushed the ado-3120-bug-cmd-s-doesnt-save-when-in-expression-editor branch from 471ad31 to 266c159 Compare March 3, 2025 13:15
Copy link

codecov bot commented Mar 3, 2025

Codecov Report

Attention: Patch coverage is 95.23810% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ntend/editor-ui/src/components/NodeDetailsView.vue 95.23% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Cadiac Cadiac marked this pull request as ready for review March 3, 2025 13:30
@n8n-assistant n8n-assistant bot added the n8n team Authored by the n8n team label Mar 3, 2025
@CharlieKolb
Copy link
Contributor

This looks great! Love the tests in particular. One complication to be aware of is that the NodeCreator (right hand + button to add nodes) and the AI Assistant (needs some local setup, shoot me a dm if you want to try this) both also do some custom listening.

Your code handles this fine though, typing in the AI Assistant still works while on the NDV, and while the NDV is open cmd+s saves (without it open the existing behavior of the pop up remains, which is fine or follow up at worst)

CharlieKolb
CharlieKolb previously approved these changes Mar 3, 2025
Copy link
Contributor

@CharlieKolb CharlieKolb left a comment

Choose a reason for hiding this comment

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

Code looks good to me, and everything works well locally 🙌

Copy link

cypress bot commented Mar 3, 2025

n8n    Run #9628

Run Properties:  status check passed Passed #9628  •  git commit 1c4f16ae34: 🌳 🖥️ browsers:node18.12.0-chrome107 🤖 Cadiac 🗃️ e2e/*
Project n8n
Branch Review ado-3120-bug-cmd-s-doesnt-save-when-in-expression-editor
Run status status check passed Passed #9628
Run duration 04m 40s
Commit git commit 1c4f16ae34: 🌳 🖥️ browsers:node18.12.0-chrome107 🤖 Cadiac 🗃️ e2e/*
Committer Jaakko Husso
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 2
Tests that did not run due to a developer annotating a test with .skip  Pending 5
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 440
View all changes introduced in this branch ↗︎

Copy link
Contributor

github-actions bot commented Mar 3, 2025

✅ All Cypress E2E specs passed

@Cadiac Cadiac requested a review from CharlieKolb March 3, 2025 19:25
@Cadiac
Copy link
Contributor Author

Cadiac commented Mar 3, 2025

Added a couple of more unit tests tests increasing coverage on the NDV, if you could take a look at this again tomorrow that would be great!

Copy link
Contributor

@CharlieKolb CharlieKolb left a comment

Choose a reason for hiding this comment

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

Really nice work 🙌

Copy link
Contributor

github-actions bot commented Mar 4, 2025

✅ All Cypress E2E specs passed

@Cadiac Cadiac merged commit 9ba9443 into master Mar 4, 2025
38 checks passed
@Cadiac Cadiac deleted the ado-3120-bug-cmd-s-doesnt-save-when-in-expression-editor branch March 4, 2025 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
n8n team Authored by the n8n team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants