From f640580463008b8c504cbe4b2675205e60642c8e Mon Sep 17 00:00:00 2001 From: CubeGameLP <126233386+CubeGameLP@users.noreply.github.com> Date: Fri, 28 Aug 2026 21:46:59 +0200 Subject: [PATCH] fix(notes): Shift+Enter in the capture box, not just in the note rows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous fix put AcceptsReturn on the rows in the DataTemplate and missed the box you actually type new notes into, which still had it off and only a KeyBinding for Enter — so Shift+Enter there did nothing. Both now go through the same tunnel handler: Enter files the note, Shift+Enter is left to the TextBox for the line break. The KeyBinding is gone; with AcceptsReturn on it could never have fired anyway, because TextBox consumes Enter in its own OnKeyDown before bindings or bubbling handlers run. Verified against the running app: a note typed with Shift+Enter is stored as "fe\r\ndwa". Co-Authored-By: Claude Opus 5 --- .../Views/Islands/NotesEditorView.axaml | 10 ++++---- .../Views/Islands/NotesEditorView.axaml.cs | 25 +++++++++++++++---- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/ClaudeDo.Ui/Views/Islands/NotesEditorView.axaml b/src/ClaudeDo.Ui/Views/Islands/NotesEditorView.axaml index 1fa35a61..b04a09f6 100644 --- a/src/ClaudeDo.Ui/Views/Islands/NotesEditorView.axaml +++ b/src/ClaudeDo.Ui/Views/Islands/NotesEditorView.axaml @@ -45,14 +45,14 @@ + - - - - + AcceptsReturn="True" TextWrapping="Wrap" + VerticalAlignment="Center" Margin="12,0,0,0"/> diff --git a/src/ClaudeDo.Ui/Views/Islands/NotesEditorView.axaml.cs b/src/ClaudeDo.Ui/Views/Islands/NotesEditorView.axaml.cs index e53bf237..dbfb02e6 100644 --- a/src/ClaudeDo.Ui/Views/Islands/NotesEditorView.axaml.cs +++ b/src/ClaudeDo.Ui/Views/Islands/NotesEditorView.axaml.cs @@ -21,6 +21,7 @@ public partial class NotesEditorView : UserControl AddHandler(KeyDownEvent, OnBulletKeyDown, RoutingStrategies.Tunnel); } + private void OnDataContextChanged(object? sender, EventArgs e) { if (_vm is not null) _vm.FocusRequested -= FocusBullet; @@ -37,13 +38,27 @@ public partial class NotesEditorView : UserControl private void OnBulletKeyDown(object? sender, KeyEventArgs e) { - // Source, not sender: the tunnel handler is attached to the whole view, so this also sees - // keys from the capture box at the top — which has no bullet behind it and is skipped. - if (e.Source is not TextBox { DataContext: NoteBulletViewModel bullet } box - || DataContext is not NotesEditorViewModel vm) return; + // Source, not sender: the tunnel handler is attached to the whole view, so it sees the + // capture box at the top as well as the note rows. Both need the same Enter/Shift+Enter + // split, and neither can get it from a KeyBinding — with AcceptsReturn on, TextBox eats + // Enter in its own OnKeyDown before any bubbling handler or binding runs. + if (e.Source is not TextBox box || DataContext is not NotesEditorViewModel vm) return; + var shift = e.KeyModifiers.HasFlag(KeyModifiers.Shift); + + if (ReferenceEquals(box, NewNoteBox)) + { + if (e.Key == Key.Enter && !shift) + { + e.Handled = true; + vm.AddBulletCommand.Execute(null); + } + return; + } + + if (box.DataContext is not NoteBulletViewModel bullet) return; // Shift+Enter falls through to the TextBox and breaks the line — a note can be several. - if (e.Key == Key.Enter && !e.KeyModifiers.HasFlag(KeyModifiers.Shift)) + if (e.Key == Key.Enter && !shift) { e.Handled = true; vm.SplitBulletCommand.Execute(bullet);