Repository navigation
Conversation
|
/backport to stable35 |
blizzz
left a comment
There was a problem hiding this comment.
Looked good to me, but Claude had some findings to consider. Claimed to have repro'd everything, apart of the A11y issue.
| if (typed?.range.from === range.from || transaction.getMeta(LinkPickerPluginKey)?.open) { | ||
| return true | ||
| } | ||
| // Keep a link picker opened by `openLinkPicker` open. `editor.state` is the state before `transaction`. | ||
| // Remote changes replace the whole document, so also compare the text. | ||
| const prev = LinkPickerPluginKey.getState(editor.state) | ||
| return prev.active | ||
| && (transaction.mapping.map(prev.range.from) === range.from || text === prev.text) |
There was a problem hiding this comment.
the picker often fails to open from the link menu
- repro: open a markdown file, put the cursor inside a word in a paragraph you haven't edited yet, then Link menu → "Open the Smart Picker".
There was a problem hiding this comment.
another case: an open picker jumps to any other / the cursor moves to
- In a document containing
Hello and/or world, put the cursor in "Hello" (e.g. Hel|lo). - Open the Link menu and choose "Open the Smart Picker". You get Hel/lo and the popup opens.
- Without typing anything, click in "and/or" right between / and o.
- Expected: the popup closes. Actual (from reading the code): the popup moves to the / in "and/or" and stays open.
- Choose an entry, e.g. a file. It replaces the / in "and/or", which gives "and" + link + "or". The stray / in "Hel/lo" stays behind.
There was a problem hiding this comment.
the picker often fails to open from the link menu
* repro: open a markdown file, put the cursor inside a word in a paragraph you haven't edited yet, then Link menu → "Open the Smart Picker".
Not reproducible for me 🤔 (also not for Claude on my end).
Do you have further details how to reproduce?
There was a problem hiding this comment.
another case: an open picker jumps to any other / the cursor moves to
Fixed.
There was a problem hiding this comment.
the picker often fails to open from the link menu
* repro: open a markdown file, put the cursor inside a word in a paragraph you haven't edited yet, then Link menu → "Open the Smart Picker".Not reproducible for me 🤔 (also not for Claude on my end).
Do you have further details how to reproduce?
Yes, but only with IME input method. I suppose this is only relevant with direct editing on Android? Not sure about iOS.
finding1-browser-repro.webm
There was a problem hiding this comment.
Thanks, that did it: paragraphs typed via IME get no text direction, and setting it when the trigger character is inserted closed the picker again. Fixed.
There was a problem hiding this comment.
Change brought a new finding, I would not say it is a blocker per se, your call: Ctrl+Z after the button can open the picker on the user's own /, and Escape then deletes it
Repro
- Create a Markdown file containing just the line
see Documents/Notesand open it in Text. - Click at the end of that line. Wait about a second, so the undo step isn't merged with your earlier typing.
- Toolbar Insert link → Open the Smart Picker. The text becomes
see Documents/Notes/and the picker opens. - Press Ctrl+Z. The
/disappears, but the picker stays open with "No suggestion found". It is now bound to the user's own/(queryNotes). - Press Escape, the usual way to close a popup. The text becomes
see Documents:/Notesis deleted, and after autosave the file on the server containssee Documents.
Mid-word variant: the same steps with the cursor at Documents/Not|es now give see Documentss now.
Results
| Scenario | After Ctrl+Z | After Escape | Saved on server |
|---|---|---|---|
End of paragraph …/Notes| |
picker open, query Notes |
see Documents |
see Documents ❌ |
Mid-word …/Not|es now |
picker open, query Note |
see Documentss now |
same ❌ |
After the word …/Notes| now (old step 1) |
closed | unchanged | unchanged ✅ |
| Enter instead of Escape | picker open | Enter is swallowed (no new line), text unchanged | unchanged |
| With the fix, end and mid-word | closed | unchanged | unchanged ✅ |
Suggested fix (verified)
import { ySyncPluginKey } from '@tiptap/y-tiptap'
…
const isRemote = isChangeOrigin(tr) && !tr.getMeta(ySyncPluginKey)?.isUndoRedoOperation
const isSameTrigger = isRemote || start === tr.mapping.map(trigger.pos)There was a problem hiding this comment.
Thanks, again a good (though minor) catch: undo comes from Yjs like remote changes, so the picker picked up the nearest /. I went with a slightly broader fix than your suggestion: for changes from Yjs, the trigger and query text must be unchanged, otherwise the picker closes. That also covers a collaborator deleting the / while the picker is open, which your variant still let through. Regression tests for both cases added.
6fa95f7 to
34407ca
Compare
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Fixes #7795 Signed-off-by: xhon-pelushi <xhon@pelushi.com>
The smart picker buttons in the menu bar and the suggestions bar now insert a `/` after the cursor or the selected text and open the inline smart picker menu, also within words. A typed `/` still only opens the menu after whitespace or at the start of a line. While an emoji, mention or smart picker suggestion menu is open, its trigger character and the text typed after it are styled like an inline input. Signed-off-by: Jonas <jonas@freesources.org> Assisted-by: ClaudeCode:claude-opus-5-5
After "Link to website" was cancelled, the URL input stayed in the link menu. NcActions then treated the menu as a dialog with a focus trap and moved focus back to the menu button after the inline smart picker had focused the editor, so typed text was lost. Signed-off-by: Jonas <jonas@freesources.org> Assisted-by: ClaudeCode:claude-opus-5-5
Opening the smart picker from the menu bar used to show an accessible dialog. The inline list it shows now had no roles and was not linked to the editor, so screen readers did not announce it or the selected entry. Signed-off-by: Jonas <jonas@freesources.org> Assisted-by: ClaudeCode:claude-opus-5-5
The check for grouped items compared the object keys, which are strings, with `undefined`, so the group headings never showed. Scrolling the selected entry into view assumed rows of equal height, which no longer holds with headings in between. Signed-off-by: Jonas <jonas@freesources.org> Assisted-by: ClaudeCode:claude-opus-5-5
The query stayed in the document while the smart picker dialog was open and after it got cancelled, and the hidden suggestion stayed active, so Enter in the text opened the dialog again. The result was also inserted at the position from before the dialog opened, which is wrong if the document changed in the meantime. Signed-off-by: Jonas <jonas@freesources.org> Assisted-by: ClaudeCode:claude-opus-5-5
…tton Deciding whether to keep the picker open compared each transaction with the editor state from before the whole dispatch, which is wrong for transactions appended by other plugins. Tracking the position of the trigger character through every transaction makes the picker robust against them and replaces the separate state for removing the trigger character on Escape. Signed-off-by: Jonas <jonas@freesources.org> Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Jonas <jonas@freesources.org> Assisted-by: ClaudeCode:claude-opus-5-5
Opening the smart picker from the menu bar with text selected inserted the picked link after the selection instead of linking it, as the smart picker dialog did before. Signed-off-by: Jonas <jonas@freesources.org> Assisted-by: ClaudeCode:claude-opus-5-5
The inline picker needs a collapsed cursor for its query, so the selection got lost when opening it with text selected. The selected text now stays highlighted and gets selected again when the picker or the smart picker dialog is cancelled. Signed-off-by: Jonas <jonas@freesources.org> Assisted-by: ClaudeCode:claude-opus-5-5
34407ca to
2846ed3
Compare
…on undo Undo and redo come from Yjs like remote changes. The picker then looked for the trigger character in front of the cursor and could pick up a slash typed by the user, which Escape would delete. Signed-off-by: Jonas <jonas@freesources.org> Assisted-by: ClaudeCode:claude-opus-5-5
📝 Summary
The smart picker buttons in the menu bar and the suggestions bar now insert a
/after the cursor or the selected text and open the inline smart picker menu, also within words. A typed/still only opens the menu after whitespace or at the start of a line.While an emoji, mention or smart picker suggestion menu is open, its trigger character and the text typed after it are styled like an inline input.
🏁 Checklist
npm run lint/npm run stylelint/composer run cs:check)🤖 AI (if applicable)