mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-19 23:50:51 +00:00
fix: quote reply in Chromium (#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. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7883 Reviewed-by: Otto <otto@codeberg.org> Co-authored-by: Gusted <postmaster@gusted.xyz> Co-committed-by: Gusted <postmaster@gusted.xyz>
This commit is contained in:
parent
7c150be23d
commit
8deb184043
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 the selection is in the comment body, then insert the quote.
|
||||||
if (quote.closest(`#${event.target.getAttribute('data-target')}`)) {
|
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'))}:`;
|
editorTextArea.value += `@${event.target.getAttribute('data-author')} wrote in ${toAbsoluteUrl(event.target.getAttribute('data-reference-url'))}:`;
|
||||||
|
|
||||||
|
quote.range = currentRange;
|
||||||
quote.insert(editorTextArea);
|
quote.insert(editorTextArea);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue