Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
[ai] stream-create: Use CSS flex layout for subscriber list height.
Sahil Batra40df1c15e7e1
diff --git a/web/src/resize.ts b/web/src/resize.tsindex 8d0e90fd676..638946112b5 100644--- a/web/src/resize.ts+++ b/web/src/resize.ts@@ -157,64 +157,6 @@ export function resize_bottom_whitespace(): void {}}-export function resize_stream_creation_subscribers_list(): void {- // Calculates the height of the subscribers list in stream creation form.- // This prevents the stream settings from overflowing the container and- // having a scroll bar.-- if ($("#channels_overlay_container").find(".two-pane-settings-overlay.show").length === 0) {- // Don't run if stream settings overlay is not open.- return;- }-- if ($("#stream_creation_form .subscribers_container").css("display") === "none") {- // Don't run if the subscribers section of the stream creation form is- // not open.- return;- }-- const $container = $("#stream_creation_form .two-pane-settings-creation-simplebar-container");- const $choose_subscribers_title = $container.find(".new-stream-subscribers-title");- const $pill_input_container = $container.find(".subscriber_list_settings");- const $subscribers_list_header = $container.find(".create_stream_subscriber_list_header");-- const elements_above_subscribers_list = [- $choose_subscribers_title,- $pill_input_container,- $subscribers_list_header,- ];-- let total_height_of_elements_above_subscribers_list = 0;- for (const $elem of elements_above_subscribers_list) {- const outer_height = $elem.outerHeight(true) ?? 0;- total_height_of_elements_above_subscribers_list += outer_height;- }-- const susbcribers_list_container_bottom_border_width = 1;- const stream_creation_body_padding = 15;- const stream_creation_section_bottom_margin = 20;-- // The two elements whose height is being calculated below- // are error elements. If no error is shown, consider height- // as 0.- const stream_subscription_error_height = $("#stream_subscription_error").height() ?? 0;- const $stream_creation_error = $container.find(".stream_create_info");- const stream_creation_error_height =- $stream_creation_error.css("display") !== "none"- ? $stream_creation_error.outerHeight(true)!- : 0;-- const subscribers_list_height =- $container.height()! -- total_height_of_elements_above_subscribers_list -- stream_creation_body_padding -- stream_creation_section_bottom_margin -- stream_subscription_error_height -- stream_creation_error_height -- susbcribers_list_container_bottom_border_width;- $(":root").css("--new-stream-subscriber-list-max-height", `${subscribers_list_height}px`);-}-export function resize_stream_filters_container(): void {resize_bottom_whitespace();$("#left_sidebar_scroll_container").css("max-height", get_stream_filters_max_height());@@ -355,5 +297,4 @@ export function resize_page_components(): void {resize_settings_overlay($("#channels_overlay_container"));resize_settings_creation_overlay($("#groups_overlay_container"));resize_settings_creation_overlay($("#channels_overlay_container"));- resize_stream_creation_subscribers_list();}diff --git a/web/src/stream_create.ts b/web/src/stream_create.tsindex e19ef3c2a18..063be0f1aef 100644--- a/web/src/stream_create.ts+++ b/web/src/stream_create.ts@@ -13,7 +13,6 @@ import {$t, $t_html} from "./i18n.ts";import * as keydown_util from "./keydown_util.ts";import * as loading from "./loading.ts";import * as onboarding_steps from "./onboarding_steps.ts";-import * as resize from "./resize.ts";import * as settings_components from "./settings_components.ts";import * as settings_config from "./settings_config.ts";import * as settings_data from "./settings_data.ts";@@ -297,7 +296,6 @@ function create_stream(): void {$t_html({defaultMessage: "The channel description cannot contain newline characters."}),$(".stream_create_info"),);- resize.resize_stream_creation_subscribers_list();return;}const subscriptions = JSON.stringify([{name: stream_name, description}]);@@ -437,7 +435,6 @@ function create_stream(): void {xhr,$(".stream_create_info"),);- resize.resize_stream_creation_subscribers_list();}loading.destroy_indicator($("#stream_creating_indicator"));},@@ -467,7 +464,6 @@ function clear_error_display(): void {stream_name_error.clear_errors();$(".stream_create_info").hide();stream_subscription_error.clear_errors();- resize.resize_stream_creation_subscribers_list();}export function show_new_stream_modal(): void {diff --git a/web/src/stream_create_subscribers.ts b/web/src/stream_create_subscribers.tsindex 11f1d7b08f4..74c6359525a 100644--- a/web/src/stream_create_subscribers.ts+++ b/web/src/stream_create_subscribers.ts@@ -7,7 +7,6 @@ import * as add_subscribers_pill from "./add_subscribers_pill.ts";import * as ListWidget from "./list_widget.ts";import type {ListWidget as ListWidgetType} from "./list_widget.ts";import * as people from "./people.ts";-import * as resize from "./resize.ts";import {current_user} from "./state_data.ts";import * as stream_create_subscribers_data from "./stream_create_subscribers_data.ts";import type {CombinedPillContainer} from "./typeahead_helper.ts";@@ -54,28 +53,18 @@ function build_pill_widget({const $pill_container = $parent_container.find(".pill-container");const get_potential_subscribers = stream_create_subscribers_data.get_potential_subscribers;const get_user_groups = user_groups.get_all_realm_user_groups;- const on_pill_create = (user_ids: number[]): void => {- add_user_ids(user_ids);- resize.resize_stream_creation_subscribers_list();- };- const on_pill_remove = (user_ids: number[]): void => {- sync_user_ids(user_ids);- resize.resize_stream_creation_subscribers_list();- };-return add_subscribers_pill.create({$pill_container,get_potential_subscribers,get_user_groups,with_add_button: false,- onPillCreateAction: on_pill_create,+ onPillCreateAction: add_user_ids,// It is better to sync the current set of user ids in the input// instead of removing user_ids from the user_ids_set, otherwise// we'll have to have more complex logic of when to remove// a user and when not to depending upon their group, channel// and individual pills.- onPillRemoveAction: on_pill_remove,- onTextInputCallback: resize.resize_stream_creation_subscribers_list,+ onPillRemoveAction: sync_user_ids,});}diff --git a/web/src/stream_settings_components.ts b/web/src/stream_settings_components.tsindex eaeccc72d47..b55f49935d1 100644--- a/web/src/stream_settings_components.ts+++ b/web/src/stream_settings_components.ts@@ -134,7 +134,10 @@ export const show_subs_pane = {$("#stream-creation").show();resize.resize_settings_overlay($("#channels_overlay_container"));resize.resize_settings_creation_overlay($("#channels_overlay_container"));- resize.resize_stream_creation_subscribers_list();+ $("#stream_creation_form .two-pane-settings-creation-simplebar-container").toggleClass(+ "subscribers-visible",+ container_name === "subscribers_container",+ );},};diff --git a/web/styles/app_variables.css b/web/styles/app_variables.cssindex 0b4dd5195f2..f14babbcce7 100644--- a/web/styles/app_variables.css+++ b/web/styles/app_variables.css@@ -741,7 +741,6 @@This value will be overridden when stream settings is opened.*/--stream-subscriber-list-max-height: 100%;- --new-stream-subscriber-list-max-height: 100%;/*Reusable dimensions and offsets.*/diff --git a/web/styles/subscriptions.css b/web/styles/subscriptions.cssindex cc4a0782101..928041ab348 100644--- a/web/styles/subscriptions.css+++ b/web/styles/subscriptions.css@@ -274,10 +274,6 @@ h4.user_group_setting_subsection_title {}}-#stream_creation_form .subscriber_list_container {- max-height: var(--new-stream-subscriber-list-max-height);-}-.subscriber-name,.subscriber-email {padding: 5px;@@ -1364,37 +1360,69 @@ h4.user_group_setting_subsection_title {.subscriber_list_settings_container {height: 100%;}+ }+ }+ }- .subscriber_list_settings_container .subscriber-list-box {- /* flex: 1 takes remaining space after the auto-sized siblings. */- flex: 1;- overflow: hidden;- /* Hide borders here since they would extend to the- full flex item height; they are redeclared on- .subscriber_list_container instead. */- border-left: none;- border-right: none;-- .subscriber_list_container {- box-sizing: border-box;- max-height: 100%;- /* overflow: clip prevents the native scrollbar that would otherwise- appear because the simplebar placeholder can overflow the- container. Unlike overflow: hidden, clip does not disable- simplebar (simplebar only disables on overflow: hidden). */- overflow: clip;- border-left: 1px solid- var(--color-border-table-subscriber-list);- border-right: 1px solid- var(--color-border-table-subscriber-list);- border-top-left-radius: 4px;- border-top-right-radius: 4px;+ .two-pane-settings-creation-simplebar-container.subscribers-visible {+ /* When the subscribers step is visible in the stream creation form,+ disable simplebar on the outer container and use flex layout so+ only the subscriber list table scrolls via its own simplebar. */+ overflow-y: hidden;++ .simplebar-content:has(> .stream-creation-body) {+ height: 100%;+ display: flex;+ flex-direction: column;++ .stream-creation-body {+ flex: 1;+ overflow: hidden;++ .subscribers_container {+ height: 100%;+ display: flex;+ flex-direction: column;++ .stream_create_add_subscriber_container,+ #people_to_add {+ flex: 1;+ overflow: hidden;+ display: flex;+ flex-direction: column;}}}}}+ #stream_settings.subscribers-tab-active .subscriber-list-box,+ .two-pane-settings-creation-simplebar-container.subscribers-visible+ .subscriber-list-box {+ /* flex: 1 takes remaining space after the auto-sized siblings. */+ flex: 1;+ overflow: hidden;+ /* Hide borders here since they would extend to the+ full flex item height; they are redeclared on+ .subscriber_list_container instead. */+ border-left: none;+ border-right: none;++ .subscriber_list_container {+ box-sizing: border-box;+ max-height: 100%;+ /* overflow: clip prevents the native scrollbar that would otherwise+ appear because the simplebar placeholder can overflow the+ container. Unlike overflow: hidden, clip does not disable+ simplebar (simplebar only disables on overflow: hidden). */+ overflow: clip;+ border-left: 1px solid var(--color-border-table-subscriber-list);+ border-right: 1px solid var(--color-border-table-subscriber-list);+ border-top-left-radius: 4px;+ border-top-right-radius: 4px;+ }+ }+#personal-stream-settings {.stream_change_property_status {margin: 9px auto 3px 3px;