-
Notifications
You must be signed in to change notification settings - Fork 452
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
Added setting to change preferred key for sending messages #4259
Conversation
6b38b43
to
c607895
Compare
37d542f
to
0c99b74
Compare
signoff bot was unhappy, I now simply squashed all, should be fine now |
@nickvergessen any objections to merging this ? |
With the setting changed, submitting:
posts this in the chat:
(Firefox 81.0) |
this https://github.com/nextcloud/spreed/pull/4259/files#diff-3fab09c19bdf3c266b808d2335831664R412 had fixed it for me in Firefox 80... hmmm, need to check more browsers then and/or fix it differently |
Prevent implicit insertion of divs when pressing Enter | ||
https://stackoverflow.com/a/24689420 | ||
*/ | ||
display: inline-block; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems to not work in FF81?
Apparently that fix only worked for Chrome, not Firefox... I did more analysis and found out that if we leave the event untouched, then:
so to be consistent we'd need to find a way to also strip the div (did a few attempts but didn't get anything consistent) |
Test result:
gives and with enter key:
gives 😞 |
made several attempts to insert a br instead of a div with
inconsistencies... |
replacing |
I went back to the original behavior of shift+enter before this PR and noticed that:
I'll see if I can also have that extra "br" there. (also need to test this with Edge and Safari...) |
When forcing having an initial "\n" inside the content editable:
I think I'll abandon this approach... Next I'll explore a hybrid approach:
|
Added checkbox in the settings dialog for users to choose between Enter and Shift+Enter for sending messages. Signed-off-by: Vincent Petry <vincent@nextcloud.com>
Since every browser uses a slightly different approach when hitting enter in a "contenteditable", we need to also post-process "div" elements and convert them to newlines. Signed-off-by: Vincent Petry <vincent@nextcloud.com>
0c99b74
to
1adf641
Compare
I give up trying to hack this further. Too much time lost for this little feature. I went with the approach where the "div" are stripped to reflect whatever the user typed in, this seems to work well most of the times. There are situations in Chromium where inserting an emoji at the end might either end up in the last div element, or sometimes it appears after it. Despite exact same steps, the behavior seems to be randomly different, based on Chromium's mood. I suggest to investigate this later as part of the "emoji insertion position issues" ticket here #4265 |
Tested with Chromium 85.0.4183.121, Firefox 80.0 and MS Edge / Win 10 from https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/ |
So, do we do this? Or is it not needed anymore with #4333 |
part for this PR will be needed for #4333 as well, at least the bits with the checkbox in settings. but also, as I heard the rich editor will not handle enter keypresses for submitting, so these still need to be done from outside @danxuliu are you fine if we move forward with this PR, knowing about future conflicts on #4333 ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danxuliu are you fine if we move forward with this PR, knowing about future conflicts on #4333 ?
Yes, I always intended to rebase #4333 on this once done, so no problem :-)
I would prefer not to use a server setting for this; I think that using the browser storage would be better in this case. Moreover that way the setting could be available for guest users too.
Also, in the new RichContenteditable
component Ctrl+Enter is the combination used for submitting. Maybe it would be better to always use Shift+Enter for new lines, Ctrl+Enter for submitting, and make configurable whether Enter sends or adds a new line?
In any case, will adding a new line instead of sending when pressing Enter solve the original issue? Even if the message is not sent it would cause a new line to be added after each character, which will require that new line to be removed before typing the next character. Better than single character messages, but still problematic I think.
Unfortunately I have not been able to reproduce the original issue. I was able to press Enter to select Hiragana and Katakana characters without sending the message with Firefox and Chromium using ibus-anthy, ibus-mozc and fictx (in this case, Pinyin, not Japanese characters, but it should not make any difference) on GNU/Linux. So it would be good if @satorunsuto could try this pull request and tell us if it fixes the issue :-)
Finally, regarding the post-processing of divs when entering new lines, it seems to be working fine based on some little tests I made. Also the code looks good, and given the extensive testing by @PVince81, 👍
@nickvergessen let's move this to backlog as it doesn't make sense to merge it before #4333 is done. When #4333 is done this PR here will need some adjustments. |
Thanks for everyone's work on this. |
A clickable button is already there |
Oops, my apologies. I somehow didn't see it. |
Waiting eagerly for #4333 to get the 'Enter key for new line' functionality +1
To chime in on this comment, being able to reproduce this issue comes down to whether or not you can type Japanese at native speed. I'm currently administering a Nextcloud instance for a small Japanese team and the problem they have is obvious. If you think about how we type, we constantly hit superfluous keys, backspace, replace, backspace, replace. Typing at native speed is definitely not a linear, mistake-free activity. When it comes to selecting certain Japanese words with the Enter key at native speed, the Enter key is being hit very frequently and often superfluously. For English, it would be like using the space-bar to send the message. You would be constantly sending one word messages. I would say this functionality - to have the Enter key insert a new line (and not send) - is essential. |
I will close the PR for now (as there was no active development since 6 months). Anyone can pick it up whenever they want and reopen the PR. |
Fixes #3268
Added checkbox in the settings dialog for users to choose
between Enter and Shift+Enter for sending messages.
The settingsStore was borrowed from #4231
Manual Tests