Skip to content

Open links in message fields with Ctrl+click - #31413

Open
meh7an wants to merge 1 commit into
telegramdesktop:devfrom
meh7an:feature/open-links-in-fields
Open

meh7an wants to merge 1 commit into
telegramdesktop:devfrom
meh7an:feature/open-links-in-fields

Conversation

@meh7an

@meh7an meh7an commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Needs desktop-app/lib_ui#383.

Links typed or formatted in the message field, in captions, while editing a message or in the article editor can't be opened from there; the context menu only offers to edit them. Most editors open a link on Ctrl+click (Cmd+click on macOS), and the message fields now do the same through the new open link callback of the lib_ui input field. While Ctrl is held over a link, the link is underlined and the cursor becomes a pointer, so it's clear what the click will open.

Links that open inside the app (a chat, a profile, a hashtag search, t.me links) are only enabled where the typed text survives the navigation: the message field, including editing, the topic, comments, scheduled and business message fields, which keep their draft, and the article editor, which has its own window. There they open text links, plain URLs and emails, usernames, mentions picked by name and hashtags the same way they open in messages. Every other field, like captions, poll and todo fields, share and forward comments, gift messages, folder names and story replies, lives in a box or the media viewer that such a navigation would close together with what was typed, so it only opens web links and emails, and opens Instant View pages in the browser. DefaultOpenLinkCallback() takes these as OpenLinkOptions, and the check follows the URL the click really opens, so Telegram links with login tokens or long t.me links aren't let through.

Hidden text links and suspicious-looking URLs still show the "Open this link?" box with the real address. Ctrl+click skips it in messages, but in a field Ctrl is the only way to open a link, so the new ClickHandlerContext::ctrlRequired keeps the confirmation, and HiddenUrlClickHandler keeps confirming telegra.ph pages when Instant View isn't tried. In story replies, the video chat message field and dark share boxes the box uses the dark label style.

Testing

Tested on macOS 27.0, in a Debug build:

  • Cmd+click in the message field opens a text link and a typed URL in the browser, and a username, a mention picked by name, a t.me link and a hashtag open the profile, the chat or the search, with the typed text kept as a draft.
  • In a poll question, a forward comment and a photo caption, only web links are underlined and they open in the browser while the box stays with its content; t.me links, usernames and hashtags aren't underlined. A telegra.ph link opens in the browser there and in Instant View from the message field.
  • https://example.com/❤️/guide and a text link with an emoji in its label are underlined and opened as a whole.
  • A pasted hidden text link shows "Open this link?" with its address, while a plain URL opens directly.
  • Holding Cmd over a link underlines it and shows the pointer, releasing Cmd removes both, and pasting next to it with Cmd held doesn't extend the underline.
  • Moving over a long paragraph full of links with Cmd held stays smooth.

@keyang556

Copy link
Copy Markdown

Thanks for working on this! This is a useful improvement.
Would it also be possible to provide a keyboard-only shortcut for opening a link at the current text cursor position?
Currently, the new functionality appears to require Ctrl+click (Cmd+click on macOS). For keyboard and screen reader users, it would be useful to have an equivalent keyboard action, for example Ctrl + another available key when the text cursor is inside a link.
Ctrl+Enter may not be suitable because it can already be used for sending messages depending on the user's send settings, but another non-conflicting shortcut could provide the same functionality as Ctrl+click.

@meh7an
meh7an force-pushed the feature/open-links-in-fields branch from 1c8d739 to 27b4465 Compare October 10, 2026 11:14
@meh7an
meh7an force-pushed the feature/open-links-in-fields branch from 27b4465 to 89fbba8 Compare October 10, 2026 11:32

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants