Fix slow mode:
focus was lost when textarea got disabled, so it could trigger some Peertube events if the user type some text.
This commit is contained in:
parent
543f18c727
commit
1ceb37da2c
@ -19,6 +19,7 @@ TODO: https://github.com/JohnXLivingston/peertube-plugin-livechat/issues/48
|
|||||||
|
|
||||||
* Some code refactoring.
|
* Some code refactoring.
|
||||||
* New translations: Galician.
|
* New translations: Galician.
|
||||||
|
* Fix slow mode: focus was lost when textarea got disabled, so it could trigger some Peertube events if the user type some text.
|
||||||
|
|
||||||
## 8.4.0
|
## 8.4.0
|
||||||
|
|
||||||
|
@ -123,3 +123,10 @@ body.converse-embedded {
|
|||||||
margin-bottom: 6px;
|
margin-bottom: 6px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.conversejs {
|
||||||
|
// Fix: for the slow mode, we use readonly instead of disabled, we must apply same CSS as ConverseJS.
|
||||||
|
textarea:read-only {
|
||||||
|
background-color: var(--chat-textarea-disabled-bg-color) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -31,15 +31,12 @@ export const slowModePlugin = {
|
|||||||
// FIXME: field could be enabled by something else (another event in ConverseJS).
|
// FIXME: field could be enabled by something else (another event in ConverseJS).
|
||||||
// This is not very important: the server will reject messages anyway.
|
// This is not very important: the server will reject messages anyway.
|
||||||
|
|
||||||
textarea.classList.add('disabled')
|
textarea.setAttribute('readonly', 'readonly')
|
||||||
textarea.setAttribute('disabled', 'disabled')
|
|
||||||
// Note: we are adding a 100ms delay.
|
// Note: we are adding a 100ms delay.
|
||||||
// To minimize the risk that user can send a message before the server will accept it
|
// To minimize the risk that user can send a message before the server will accept it
|
||||||
// (if the first message lagged for example)
|
// (if the first message lagged for example)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
textarea.classList.remove('disabled')
|
textarea.removeAttribute('readonly')
|
||||||
textarea.removeAttribute('disabled');
|
|
||||||
(textarea as HTMLTextAreaElement).focus()
|
|
||||||
}, slowModeDuration * 1000 + 100)
|
}, slowModeDuration * 1000 + 100)
|
||||||
})
|
})
|
||||||
}, 100)
|
}, 100)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user