fix: ensure deselecting presence modifier re-enables string input

This commit is contained in:
2026-06-10 19:14:33 +02:00
parent 64392c3935
commit 30d35a2368
2 changed files with 34 additions and 1 deletions
+17
View File
@@ -126,3 +126,20 @@ def test_string_filter_prefilled_states(live_server, page):
assert group_input.input_value() == "" assert group_input.input_value() == ""
assert not group_input.is_enabled() assert not group_input.is_enabled()
assert page.locator('input[name="filter-group-modifier"][value="IS_NULL"]').is_checked() assert page.locator('input[name="filter-group-modifier"][value="IS_NULL"]').is_checked()
@pytest.mark.django_db
@override_settings(ROOT_URLCONF="e2e.test_string_filter_e2e")
def test_string_filter_deselect_re_enables(live_server, page):
page.goto(live_server.url + "/test-string-filter-empty/")
name_input = page.locator('input[name="filter-name"]')
is_null_radio = page.locator('input[name="filter-name-modifier"][value="IS_NULL"]')
# 1. Click "is null" -> disables input
is_null_radio.click()
assert not name_input.is_enabled()
# 2. Click "is null" again to deselect/uncheck -> should re-enable the text input
is_null_radio.click()
assert name_input.is_enabled()
+17 -1
View File
@@ -316,7 +316,11 @@
if (!container) return; if (!container) return;
var textInput = container.querySelector('input[type="text"]'); var textInput = container.querySelector('input[type="text"]');
if (!textInput) return; if (!textInput) return;
var val = radio.value;
// Find the currently checked radio in the container
var checkedRadio = container.querySelector('input[type="radio"]:checked');
var val = checkedRadio ? checkedRadio.value : "";
if (val === "IS_NULL" || val === "NOT_NULL") { if (val === "IS_NULL" || val === "NOT_NULL") {
textInput.disabled = true; textInput.disabled = true;
textInput.value = ""; textInput.value = "";
@@ -455,9 +459,21 @@
}); });
} }
/**
* Set up event listeners for string modifier radio buttons.
*/
function setupStringFilters() {
document.querySelectorAll('input[data-string-modifier-radio]').forEach(function (radio) {
radio.addEventListener('change', function () {
window.toggleStringFilterInput(this);
});
});
}
document.addEventListener("DOMContentLoaded", function () { document.addEventListener("DOMContentLoaded", function () {
injectSearchInputs(); injectSearchInputs();
setupDeselectableRadios(); setupDeselectableRadios();
setupStringFilters();
loadPresets(); loadPresets();
}); });
})(); })();