diff --git a/web/src/settings_components.ts b/web/src/settings_components.ts index 130a949c51..66992e0746 100644 --- a/web/src/settings_components.ts +++ b/web/src/settings_components.ts @@ -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([ ["can_add_members_group", null], ["can_join_group", null], diff --git a/web/src/user_group_create.ts b/web/src/user_group_create.ts index 1790d6f79a..51b9c2e7e9 100644 --- a/web/src/user_group_create.ts +++ b/web/src/user_group_create.ts @@ -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", diff --git a/web/src/user_group_edit.js b/web/src/user_group_edit.js index e300184873..3e79358969 100644 --- a/web/src/user_group_edit.js +++ b/web/src/user_group_edit.js @@ -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); } }