Only reset character counters when they are present

Co-authored-by: Andreas Nedbal <git@pixelde.su>
This commit is contained in:
Karina Kwiatek 2023-01-08 18:51:43 +01:00
parent 2e7fca67fa
commit cfba963b55
2 changed files with 4 additions and 6 deletions

View File

@ -24,10 +24,6 @@ export function questionboxAllHandler(event: Event): void {
document.querySelector<HTMLInputElement>('textarea[name=qb-all-question]').value = '';
const modal = Modal.getInstance(document.querySelector('#modal-ask-followers'));
modal.hide();
// FIXME: also solve this using a Stimulus controller
const characterCount = document.querySelector<HTMLElement>('#modal-ask-followers [data-character-count-max-value]').dataset.characterCountMaxValue;
document.querySelector<HTMLElement>('#modal-ask-followers [data-character-count-target="counter"]').innerHTML = characterCount;
}
showNotification(data.message, data.success);

View File

@ -30,8 +30,10 @@ export function questionboxUserHandler(event: Event): void {
document.querySelector<HTMLInputElement>('textarea[name=qb-question]').value = '';
// FIXME: also solve this using a Stimulus controller
const characterCount = document.querySelector<HTMLElement>('#question-box[data-character-count-max-value]').dataset.characterCountMaxValue;
document.querySelector<HTMLElement>('#question-box [data-character-count-target="counter"]').innerHTML = characterCount;
const questionBox = document.getElementById('question-box');
if ('characterCountMaxValue' in questionBox.dataset) {
questionBox.querySelector<HTMLElement>('[data-character-count-target="counter"]').innerHTML = questionBox.dataset.characterCountMaxValue;
}
if (promote) {
const questionbox = document.querySelector('#question-box');