fix(StatusChatInput): missbehavior when text exceeds 2000 chars

Closes #5107
This commit is contained in:
Alexandra Betouni 2022-04-07 22:25:03 +03:00 committed by Iuri Matias
parent 70b6acce16
commit 8ece8e9fd1
1 changed files with 25 additions and 17 deletions

View File

@ -945,6 +945,7 @@ Rectangle {
TextArea {
id: messageInputField
property var lastClick: 0
property int cursorWhenPressed: 0
textFormat: Text.RichText
font.pixelSize: 15
font.family: Style.current.fontRegular.name
@ -958,6 +959,7 @@ Rectangle {
Keys.onPressed: {
keyEvent = event;
onKeyPress(event)
cursorWhenPressed = cursorPosition;
}
Keys.onReleased: onRelease(event) // gives much more up to date cursorPosition
Keys.onShortcutOverride: event.accepted = isUploadFilePressed(event)
@ -1006,6 +1008,7 @@ Rectangle {
}
}
onTextChanged: {
if (length <= control.messageLimit) {
var symbols = ":='xX><0O;*dB8-D#%\\";
if ((length > 1) && (symbols.indexOf(getText((cursorPosition - 2), (cursorPosition - 1))) !== -1)
&& (!getText((cursorPosition - 7), cursorPosition).includes("http"))) {
@ -1020,6 +1023,11 @@ Rectangle {
if (text === "") {
mentionsPos = [];
}
} else {
var removeFrom = (cursorPosition < messageLimit) ? cursorWhenPressed : messageLimit;
remove(removeFrom, cursorPosition);
}
messageLengthLimit.remainingChars = (messageLimit - length);
}
onReleased: function (event) {
@ -1146,15 +1154,15 @@ Rectangle {
StyledText {
id: messageLengthLimit
property int remainingChars: messageLimit - messageInputField.length
text: remainingChars.toString()
visible: remainingChars <= control.messageLimitVisible
color: (remainingChars <= 0) ? Style.current.danger : Style.current.textColor
property int remainingChars: -1
anchors.right: parent.right
anchors.bottom: actions.top
anchors.rightMargin: control.isStatusUpdateInput ? Style.current.padding : Style.current.radius
leftPadding: Style.current.halfPadding
rightPadding: Style.current.halfPadding
visible: ((messageInputField.length >= control.messageLimitVisible) && (messageInputField.length <= control.messageLimit))
color: (remainingChars <= messageLimitVisible) ? Style.current.danger : Style.current.textColor
text: visible ? remainingChars.toString() : ""
}
Item {