mirror of https://github.com/zulip/zulip.git
dropdown_list_widget: Hide 'disable' button when nothing is selected.
Hides 'disable' button of any kind when nothing is selected in dropdown list widgets by removing ':enabled' selector from the button, the button is not actually a button, it's an <a> tag which doesn't support "disabled" attribute. Fixes part of #20831.
This commit is contained in:
parent
df1d395d4e
commit
c355feea0e
|
@ -27,7 +27,7 @@ const {DropdownListWidget, MultiSelectDropdownListWidget} = zrequire("dropdown_l
|
|||
const setup_dropdown_zjquery_data = (name) => {
|
||||
const input_group = $(".input_group");
|
||||
const reset_button = $(".dropdown_list_reset_button");
|
||||
input_group.set_find_results(".dropdown_list_reset_button:enabled", reset_button);
|
||||
input_group.set_find_results(".dropdown_list_reset_button", reset_button);
|
||||
$(`#${CSS.escape(name)}_widget #${CSS.escape(name)}_name`).closest = () => input_group;
|
||||
const $widget = $(`#${CSS.escape(name)}_widget #${CSS.escape(name)}_name`);
|
||||
return {reset_button, $widget};
|
||||
|
|
|
@ -831,7 +831,7 @@ test("misc", ({override_rewire}) => {
|
|||
|
||||
const stub_notification_disable_parent = $.create("<stub notification_disable parent");
|
||||
stub_notification_disable_parent.set_find_results(
|
||||
".dropdown_list_reset_button:enabled",
|
||||
".dropdown_list_reset_button",
|
||||
$.create("<disable link>"),
|
||||
);
|
||||
|
||||
|
@ -906,7 +906,7 @@ test("misc", ({override_rewire}) => {
|
|||
];
|
||||
const dropdown_list_parent = $.create("<list parent>");
|
||||
dropdown_list_parent.set_find_results(
|
||||
".dropdown_list_reset_button:enabled",
|
||||
".dropdown_list_reset_button",
|
||||
$.create("<disable button>"),
|
||||
);
|
||||
for (const name of widget_settings) {
|
||||
|
|
|
@ -43,7 +43,7 @@ export function DropdownListWidget({
|
|||
DropdownListWidget.prototype.render_default_text = function (elem) {
|
||||
elem.text(this.default_text);
|
||||
elem.addClass("text-warning");
|
||||
elem.closest(".input-group").find(".dropdown_list_reset_button:enabled").hide();
|
||||
elem.closest(".input-group").find(".dropdown_list_reset_button").hide();
|
||||
};
|
||||
|
||||
DropdownListWidget.prototype.render = function (value) {
|
||||
|
@ -67,7 +67,7 @@ DropdownListWidget.prototype.render = function (value) {
|
|||
const text = this.render_text(item.name);
|
||||
elem.text(text);
|
||||
elem.removeClass("text-warning");
|
||||
elem.closest(".input-group").find(".dropdown_list_reset_button:enabled").show();
|
||||
elem.closest(".input-group").find(".dropdown_list_reset_button").show();
|
||||
};
|
||||
|
||||
DropdownListWidget.prototype.update = function (value) {
|
||||
|
@ -320,7 +320,7 @@ MultiSelectDropdownListWidget.prototype.render_button_text = function (elem, lim
|
|||
|
||||
elem.text(text);
|
||||
elem.removeClass("text-warning");
|
||||
elem.closest(".input-group").find(".dropdown_list_reset_button:enabled").show();
|
||||
elem.closest(".input-group").find(".dropdown_list_reset_button").show();
|
||||
};
|
||||
|
||||
// Override the DrodownListWidget `render` function.
|
||||
|
|
Loading…
Reference in New Issue