mirror of https://github.com/zulip/zulip.git
user_groups: Open group setting typeahead on clicking label.
Fixes #32007.
This commit is contained in:
parent
5980f4a502
commit
4a2f126af9
|
@ -1417,6 +1417,21 @@ export function initialize_disable_btn_hint_popover(
|
|||
tippy.default(util.the($btn_wrapper), tippy_opts);
|
||||
}
|
||||
|
||||
export function enable_opening_typeahead_on_clicking_label($container: JQuery): void {
|
||||
const $group_setting_labels = $container.find(".group-setting-label");
|
||||
$group_setting_labels.on("click", (e) => {
|
||||
// Click opens the typeahead.
|
||||
$(e.target).siblings(".pill-container").find(".input").expectOne().trigger("click");
|
||||
// Focus puts the cursor into the input.
|
||||
$(e.target).siblings(".pill-container").find(".input").expectOne().trigger("focus");
|
||||
});
|
||||
}
|
||||
|
||||
export function disable_opening_typeahead_on_clicking_label($container: JQuery): void {
|
||||
const $group_setting_labels = $container.find(".group-setting-label");
|
||||
$group_setting_labels.off("click");
|
||||
}
|
||||
|
||||
export const group_setting_widget_map = new Map<string, GroupSettingPillContainer | null>([
|
||||
["can_add_members_group", null],
|
||||
["can_join_group", null],
|
||||
|
|
|
@ -253,6 +253,9 @@ export function set_up_handlers(): void {
|
|||
}
|
||||
});
|
||||
|
||||
// This will always be enabled when creating a user group.
|
||||
settings_components.enable_opening_typeahead_on_clicking_label($container);
|
||||
|
||||
can_add_members_group_widget = settings_components.create_group_setting_widget({
|
||||
$pill_container: $container.find(".can-add-members-group-container .pill-container"),
|
||||
setting_name: "can_add_members_group",
|
||||
|
|
|
@ -121,6 +121,7 @@ function update_group_permission_settings_elements(group) {
|
|||
$permission_pill_container_elements.each(function () {
|
||||
$(this)[0]._tippy?.destroy();
|
||||
});
|
||||
settings_components.enable_opening_typeahead_on_clicking_label($group_permission_settings);
|
||||
} else {
|
||||
$permission_pill_container_elements.find(".input").prop("contenteditable", false);
|
||||
|
||||
|
@ -132,6 +133,7 @@ function update_group_permission_settings_elements(group) {
|
|||
$t({defaultMessage: "You do not have permission to edit this setting."}),
|
||||
);
|
||||
});
|
||||
settings_components.disable_opening_typeahead_on_clicking_label($group_permission_settings);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue