Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

bots: Improve scrolling to show API key error in manage bot form.

Sahil Batrac5b4f647cb32
diff --git a/web/src/bot_helper.ts b/web/src/bot_helper.ts
index 5590255c9ca..0290fd36ab0 100644
--- a/web/src/bot_helper.ts
+++ b/web/src/bot_helper.ts
@@ -14,7 +14,6 @@ import * as clipboard_handler from "./clipboard_handler.ts";
import {show_copied_confirmation} from "./copied_tooltip.ts";
import * as dialog_widget from "./dialog_widget.ts";
import {$t_html} from "./i18n.ts";
-import * as scroll_util from "./scroll_util.ts";
import {realm} from "./state_data.ts";
export function validate_bot_short_name(value: string): boolean {
@@ -146,10 +145,7 @@ export async function show_api_key_modal(bot_id: number): Promise<void> {
);
if (!api_key) {
- scroll_util.scroll_element_into_container(
- $("#bot-edit-form-error"),
- $("#user-profile-modal .modal__content"),
- );
+ $("#bot-edit-form").closest(".simplebar-content-wrapper").animate({scrollTop: 0}, "fast");
return;
}
@@ -212,6 +208,9 @@ export function initialize_bot_click_handlers(): void {
const bot_email = $bot_info.attr("data-email");
const api_key = await fetch_bot_api_key(bot_id, $("#bot-edit-form-error"), $(this));
if (!api_key) {
+ $("#bot-edit-form")
+ .closest(".simplebar-content-wrapper")
+ .animate({scrollTop: 0}, "fast");
return;
}
@@ -229,6 +228,9 @@ export function initialize_bot_click_handlers(): void {
const bot = bot_data.get(bot_id)!;
const api_key = await fetch_bot_api_key(bot_id, $("#bot-edit-form-error"), $(this));
if (!api_key) {
+ $("#bot-edit-form")
+ .closest(".simplebar-content-wrapper")
+ .animate({scrollTop: 0}, "fast");
return;
}
diff --git a/web/src/user_profile.ts b/web/src/user_profile.ts
index b65a0c466ce..f6cee6095e1 100644
--- a/web/src/user_profile.ts
+++ b/web/src/user_profile.ts
@@ -44,7 +44,6 @@ import * as modals from "./modals.ts";
import * as peer_data from "./peer_data.ts";
import * as people from "./people.ts";
import type {User} from "./people.ts";
-import * as scroll_util from "./scroll_util.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";
@@ -1127,10 +1126,9 @@ export function show_edit_bot_info_modal(user_id: number, $container: JQuery): v
$button,
);
if (!api_key) {
- scroll_util.scroll_element_into_container(
- $("#bot-edit-form-error"),
- $("#user-profile-modal .modal__content"),
- );
+ $("#bot-edit-form")
+ .closest(".simplebar-content-wrapper")
+ .animate({scrollTop: 0}, "fast");
return;
}
integration_url_modal.show_generate_integration_url_modal(api_key);