dropdown-list-widget: Properly handle disabled state.

We wrap the [reset] anchor tag in a button so that we can set 'disabled'
attribute on it. We change the styles to hide the [reset] button and the
pencil icon when the widget is disabled.

We also need to call `e.preventDefault()` in the event handler since now
the anchor tag behaves as a button.
This commit is contained in:
Rohitt Vashishtha
2020-05-19 10:31:53 +05:30
committed by Tim Abbott
parent f4e70714b4
commit 4d14ba41ba
5 changed files with 23 additions and 9 deletions

View File

@@ -14,7 +14,7 @@ const setup_zjquery_data = (name) => {
$.clear_all_elements();
const input_group = $(".input_group");
const reset_button = $('.dropdown_list_reset_button');
input_group.set_find_results('.dropdown_list_reset_button', reset_button);
input_group.set_find_results('.dropdown_list_reset_button:not([disabled])', reset_button);
$(`#${name}_widget #${name}_name`).closest = () => input_group;
const $widget = $(`#${name}_widget #${name}_name`);
return {reset_button, $widget};