Skip to content

fix(link-picker): open smart picker inline from buttons - #9588

Open
mejo- wants to merge 11 commits into
mainfrom
fix/inline-smart-picker
Open

mejo- wants to merge 11 commits into
mainfrom
fix/inline-smart-picker

Conversation

@mejo-

@mejo- mejo- commented Nov 10, 2026

Copy link
Copy Markdown
Member

📝 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

  • Code is properly formatted (npm run lint / npm run stylelint / composer run cs:check)
  • Sign-off message is added to all commits
  • Tests (unit, integration and/or end-to-end) passing and the changes are covered with tests

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI tools
  • The AI-generated content was reviewed, comprehended and tested by a human

@mejo- mejo- self-assigned this Nov 10, 2026
@mejo- mejo- added bug Something isn't working 3. to review labels Nov 10, 2026
@github-project-automation github-project-automation Bot moved this to 🧭 Planning evaluation (don't pick) in 📝 Productivity team Nov 10, 2026
@mejo- mejo- moved this from 🧭 Planning evaluation (don't pick) to 👀 In review in 📝 Productivity team Nov 10, 2026
@nextcloud-command nextcloud-command added the AI assisted This PR contains AI-assisted commits label Nov 10, 2026
@mejo-

mejo- commented Nov 16, 2026

Copy link
Copy Markdown
Member Author

/backport to stable35

@blizzz blizzz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looked good to me, but Claude had some findings to consider. Claimed to have repro'd everything, apart of the A11y issue.

Comment thread src/extensions/LinkPicker.js Outdated
Comment on lines +35 to +42
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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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".

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

another case: an open picker jumps to any other / the cursor moves to

  1. In a document containing Hello and/or world, put the cursor in "Hello" (e.g. Hel|lo).
  2. Open the Link menu and choose "Open the Smart Picker". You get Hel/lo and the popup opens.
  3. Without typing anything, click in "and/or" right between / and o.
  4. Expected: the popup closes. Actual (from reading the code): the popup moves to the / in "and/or" and stays open.
  5. 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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

another case: an open picker jumps to any other / the cursor moves to

Fixed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

  1. Create a Markdown file containing just the line see Documents/Notes and open it in Text.
  2. Click at the end of that line. Wait about a second, so the undo step isn't merged with your earlier typing.
  3. Toolbar Insert link → Open the Smart Picker. The text becomes see Documents/Notes/ and the picker opens.
  4. Press Ctrl+Z. The / disappears, but the picker stays open with "No suggestion found". It is now bound to the user's own / (query Notes).
  5. Press Escape, the usual way to close a popup. The text becomes see Documents: /Notes is deleted, and after autosave the file on the server contains see 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)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

Comment thread src/extensions/LinkPicker.js Resolved
@mejo-
mejo- requested a review from blizzz November 30, 2026 16:25
@mejo-
mejo- force-pushed the fix/inline-smart-picker branch from 6fa95f7 to 34407ca Compare November 30, 2026 16:26
@codecov

codecov Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

xhon-pelushi and others added 10 commits December 1, 2026 12:56
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
@mejo-
mejo- force-pushed the fix/inline-smart-picker branch from 34407ca to 2846ed3 Compare December 1, 2026 11:58
…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

This branch has not been deployed

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

Labels

3. to review AI assisted This PR contains AI-assisted commits backport-request bug Something isn't working

Projects

Status: 👀 In review

Development

Successfully merging this pull request may close these issues.

Remove smart picker dialog from text

4 participants