Bug 488585 - Shift-Return in KDE Connect SMS inserts newline at the end of field, not at cursor location
Summary: Shift-Return in KDE Connect SMS inserts newline at the end of field, not at c...
Status: RESOLVED FIXED
Alias: None
Product: kdeconnect
Classification: Applications
Component: messaging-application (other bugs)
Version First Reported In: 24.05.1
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Simon Redman
URL:
Keywords: junior-jobs
Depends on:
Blocks:
 
Reported: 2024-06-16 15:36 UTC by Jiří Wolker
Modified: 2024-06-28 11:19 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jiří Wolker 2024-06-16 15:36:41 UTC
SUMMARY

When composing a message in KDE Connect SMS app, pressing Shift-Return in the message input field should insert the newline at the location of the cursor, replacing the selection if a selection is not empty, as many other messaging apps do.

Related source code part:

https://invent.kde.org/network/kdeconnect-kde/-/blob/master/smsapp/qml/SendingArea.qml?ref_type=heads#L87

STEPS TO REPRODUCE
1. Start writing a new SMS.
2. Enter some text (≥ 2 chars) to the field.
3. Place the cursor at any position except the end.
4. Press Shift-Return.

OBSERVED RESULT

A newline is appended to the complete end of the message.

EXPECTED RESULT

The newline should be placed at the cursor, replacing the selection (if applicable).

SOFTWARE/OS VERSIONS

KDE Connect 24.05.1 (currently version)
Comment 1 Simon Redman 2024-06-24 21:15:12 UTC
Confirmed this behavior. Thanks for the report.

This is pretty clear looking at the code in smsapp/qml/SendingArea.qml, line 84 on, that it appends the newline to the text entry field:

Keys.onReturnPressed: event => {
    if (event.key === Qt.Key_Return) {
        if (event.modifiers & Qt.ShiftModifier) {
            messageField.append("")
        } else {
            sendButton.clicked()
            event.accepted = true
        }
    }
}

I can't think of a way to improve this code off-hand. Tagging this as a junior job since it's probably a simple change, just needs someone to spend a little time researching the right solution and test it.
Comment 2 Bug Janitor Service 2024-06-27 22:41:43 UTC
A possibly relevant merge request was started @ https://invent.kde.org/network/kdeconnect-kde/-/merge_requests/695
Comment 3 Albert Vaca Cintora 2024-06-28 11:19:51 UTC
Git commit d03e964ed77a980b027e53f5d6534625a9a8218b by Albert Vaca Cintora, on behalf of Ryan Frew.
Committed on 28/06/2024 at 11:19.
Pushed by albertvaka into branch 'master'.

Corrected newline inserting when using shift+return while writing SMS messages

Shift+return was always inserting newline at the end of the current line of text, ignoring where the cursor was, and not overriding currently selected text

M  +3    -1    smsapp/qml/SendingArea.qml

https://invent.kde.org/network/kdeconnect-kde/-/commit/d03e964ed77a980b027e53f5d6534625a9a8218b