settings: Close date-picker when settings modal is closed.

Previously, if the user closes the settings modal by pressing
the "Esc" key and if any date-pickers were open then they would
remain on the screen. This commit fixes that and now date-pickers
are closed when the settings modal is closed.

Also added a puppeteer test to verify the said behavior.

Fixes part of #25097.
This commit is contained in:
Satyam Bansal 2023-05-10 23:35:03 +05:30 committed by Tim Abbott
parent 557d80965c
commit b3196e5310
2 changed files with 14 additions and 0 deletions

View File

@ -34,6 +34,16 @@ async function open_settings(page: Page): Promise<void> {
);
}
async function close_settings_and_date_picker(page: Page): Promise<void> {
const date_picker_selector = ".custom_user_field_value.datepicker.form-control";
await page.click(date_picker_selector);
await page.waitForSelector(".flatpickr-calendar", {visible: true});
await page.keyboard.press("Escape");
await page.waitForSelector(".flatpickr-calendar", {hidden: true});
}
async function test_change_full_name(page: Page): Promise<void> {
await page.click("#full_name");
@ -439,6 +449,8 @@ async function test_notifications_section(page: Page): Promise<void> {
async function settings_tests(page: Page): Promise<void> {
await common.log_in(page);
await open_settings(page);
await close_settings_and_date_picker(page);
await open_settings(page);
await test_change_full_name(page);
await test_alert_words_section(page);
await test_your_bots_section(page);

View File

@ -7,6 +7,7 @@ import render_settings_tab from "../templates/settings_tab.hbs";
import * as blueslip from "./blueslip";
import * as browser_history from "./browser_history";
import * as flatpickr from "./flatpickr";
import {$t, $t_html} from "./i18n";
import * as overlays from "./overlays";
import {page_params} from "./page_params";
@ -128,6 +129,7 @@ export function open_settings_overlay() {
$overlay: $("#settings_overlay_container"),
on_close() {
browser_history.exit_overlay();
flatpickr.close_all();
},
});
}