diff options
author | silverwind <me@silverwind.io> | 2022-08-16 23:05:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-17 00:05:40 +0300 |
commit | 1e0fcd1450200e0459849edac4c0610489d251e9 (patch) | |
tree | fa995f1431826ec3e0db37d23d5a1f8a7f8e4960 /web_src | |
parent | 82f89ff996b40e30a7790d13dfa5fa8949a6d620 (diff) | |
download | gitea-1e0fcd1450200e0459849edac4c0610489d251e9.tar.gz gitea-1e0fcd1450200e0459849edac4c0610489d251e9.zip |
Fix tooltip init after review (#20814)
* Fix tooltip init after review
Previous code passed a jQuery collection which initTooltip couldn't
handle. Instead, iterate the individial matched elements and add a
dollar to the variable name to make it clear it's jQuery.
Fixes: https://github.com/go-gitea/gitea/issues/20809
Diffstat (limited to 'web_src')
-rw-r--r-- | web_src/js/features/repo-diff.js | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/web_src/js/features/repo-diff.js b/web_src/js/features/repo-diff.js index 59e0c147d9..0a59bcf1c2 100644 --- a/web_src/js/features/repo-diff.js +++ b/web_src/js/features/repo-diff.js @@ -44,24 +44,28 @@ export function initRepoDiffConversationForm() { $(document).on('submit', '.conversation-holder form', async (e) => { e.preventDefault(); - const form = $(e.target); - const $textArea = form.find('textarea'); + const $form = $(e.target); + const $textArea = $form.find('textarea'); if (!validateTextareaNonEmpty($textArea)) { return; } - const newConversationHolder = $(await $.post(form.attr('action'), form.serialize())); - const {path, side, idx} = newConversationHolder.data(); + const formDataString = String(new URLSearchParams(new FormData($form[0]))); + const $newConversationHolder = $(await $.post($form.attr('action'), formDataString)); + const {path, side, idx} = $newConversationHolder.data(); - initTooltip(newConversationHolder.find('.tooltip')); - form.closest('.conversation-holder').replaceWith(newConversationHolder); - if (form.closest('tr').data('line-type') === 'same') { + $newConversationHolder.find('.tooltip').each(function () { + initTooltip(this); + }); + + $form.closest('.conversation-holder').replaceWith($newConversationHolder); + if ($form.closest('tr').data('line-type') === 'same') { $(`[data-path="${path}"] a.add-code-comment[data-idx="${idx}"]`).addClass('invisible'); } else { $(`[data-path="${path}"] a.add-code-comment[data-side="${side}"][data-idx="${idx}"]`).addClass('invisible'); } - newConversationHolder.find('.dropdown').dropdown(); - initCompReactionSelector(newConversationHolder); + $newConversationHolder.find('.dropdown').dropdown(); + initCompReactionSelector($newConversationHolder); }); |