Skip to content

Commit

Permalink
fix(js): fix filter handling on search page
Browse files Browse the repository at this point in the history
- use insert at caret when editing on advanced search
- trigger update event to render insterted value

Fixes #11643
  • Loading branch information
nijel committed May 16, 2024
1 parent cd98d9d commit b5f01b1
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions weblate/static/loader-bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -1027,11 +1027,20 @@ $(function () {
}

if ($group.hasClass("query-field")) {
$group.find("textarea[name=q]").val($this.data("field"));
if ($this.closest(".result-page-form").length) {
if (
$(".search-toolbar").length === 0 &&
$this.closest(".result-page-form").length > 0
) {
const textarea = $group.find("textarea[name=q]");
textarea.val($this.data("field"));
textarea[0].dispatchEvent(new Event("change", { bubbles: true }));
const $form = $this.closest("form");
$form.find("input[name=offset]").prop("disabled", true);
$form.submit();
} else {
$group
.find("textarea[name=q]")
.insertAtCaret(` ${$this.data("field")} `);
}
}
$this.closest("ul").dropdown("toggle");
Expand Down

0 comments on commit b5f01b1

Please sign in to comment.