mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-04 09:25:22 +02:00
[v11.0/forgejo] fix: quote reply in Chromium (#7886)
**Backport:** https://codeberg.org/forgejo/forgejo/pulls/7883 - Chromium would unselect the text if some text is written in another element, so temporarily store the range and restore after this writing has happened. - Resolves forgejo/forgejo#7841 - No E2E test, there is already a test case that perfectly matches the reproduce steps of this bug, however Chromium does not produce consistent behavior on this case. Co-authored-by: Gusted <postmaster@gusted.xyz> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7886 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org> Co-committed-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org>
This commit is contained in:
parent
1ca805933f
commit
f13147a019
1 changed files with 5 additions and 0 deletions
|
@ -685,7 +685,12 @@ function initRepoIssueCommentEdit() {
|
|||
|
||||
// If the selection is in the comment body, then insert the quote.
|
||||
if (quote.closest(`#${event.target.getAttribute('data-target')}`)) {
|
||||
// Chromium quirk: Temporarily store the range so it doesn't get lost, caused by appending text in another element.
|
||||
const currentRange = quote.range;
|
||||
|
||||
editorTextArea.value += `@${event.target.getAttribute('data-author')} wrote in ${toAbsoluteUrl(event.target.getAttribute('data-reference-url'))}:`;
|
||||
|
||||
quote.range = currentRange;
|
||||
quote.insert(editorTextArea);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue