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(chat): preserve selection (caret) on new message input #14069

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ShGKme
Copy link
Contributor

@ShGKme ShGKme commented Jan 3, 2025

☑️ Resolves

Preserve new message input's selection (caret position) on blur and restore on focus.
Currently only useful for emoji picker, but can be useful in other inserts.

Using preserved selection, emoji picker inserts the selected emoji in the correct position.

Additional change: after the emoji picker close, the focus returns to the field.

🖌️ UI Checklist

🖼️ Screenshots / Screencasts

Works:

  • In the end
  • In the middle
  • With replace
  • Having new lines and mentions (without adding <br>)
  • Opening the picker by mouse, by SHIFT+Tab + Enter
  • Closing the picker by ESC, by click outside, by click on the trigger

replace

🏁 Checklist

  • 🌏 Tested with different browsers / clients:
    • Chromium (Chrome / Edge / Opera / Brave)
    • Firefox
    • Safari
    • Talk Desktop
    • Not risky to browser differences / client
  • 🖌️ Design was reviewed, approved or inspired by the design team
  • ⛑️ Tests are included or not possible
  • 📗 User documentation in https://github.com/nextcloud/documentation/tree/master/user_manual/talk has been updated or is not required

@ShGKme ShGKme added 3. to review bug feature: chat 💬 Chat and system messages labels Jan 3, 2025
@ShGKme ShGKme added this to the 🖤 Next Major (31) milestone Jan 3, 2025
@ShGKme ShGKme requested review from DorraJaouad and Antreesy January 3, 2025 17:36
@ShGKme ShGKme self-assigned this Jan 3, 2025
Copy link
Member

@nickvergessen nickvergessen left a comment

Choose a reason for hiding this comment

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

Not risky to browser differences / client

From my past memory (at phpBB with BBCodes, as well as Nextcloud with the mentions bubbles) this is giving me nightmares. This needs proper testing on each supported browser / platform combination before merging:

  • Desktop Client
  • Windows / Firefox
  • Windows / Chromium
  • Linux / Firefox
  • Linux / Chromium
  • Mac OS / Firefox
  • Mac OS / Chromium
  • Mac OS / Safari
  • iPhone/iPad / Safari Mobile
  • Android / Firefox
  • Android / Chrome

Testcases:

  • In the end
  • In the middle
  • With replace
  • Having new lines and mentions (without adding <br>)
  • With replacing new lines and mentions
  • Opening the picker by mouse, by SHIFT+Tab + Enter
  • Closing the picker by ESC, by click outside, by click on the trigger

Not sure which browser/OS it was, but I remember multiple selections being a thing? If that is correct we also need to test this 🙈

@ShGKme ShGKme marked this pull request as draft January 5, 2025 12:22
@ShGKme
Copy link
Contributor Author

ShGKme commented Jan 6, 2025

Testcases:

All mentioned testcases are cross-platform.

Problematic testcases:

  • Select, then turn into "Edit message" mode
  • Multi-selection, when the first range is outside the field

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Emoji not always inserted at the correct position
2 participants