From 54f51cbfa67972c04fee159950de078a214fed16 Mon Sep 17 00:00:00 2001 From: Marton Date: Tue, 12 Nov 2024 00:24:38 +0100 Subject: [PATCH] app: Fix market page form close (#3053) Fixes a bug related to closing popups on the market page. --- client/webserver/site/src/js/forms.ts | 7 ++++--- client/webserver/site/src/js/markets.ts | 17 +++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/client/webserver/site/src/js/forms.ts b/client/webserver/site/src/js/forms.ts index 6c5ea715cd..d5b865a859 100644 --- a/client/webserver/site/src/js/forms.ts +++ b/client/webserver/site/src/js/forms.ts @@ -63,7 +63,7 @@ interface WalletConfig { } interface FormsConfig { - closed?: () => void + closed?: (closedForm: PageElement | undefined) => void } export class Forms { @@ -71,7 +71,7 @@ export class Forms { currentForm: PageElement | undefined currentFormID: string | undefined keyup: (e: KeyboardEvent) => void - closed?: () => void + closed?: (closedForm: PageElement | undefined) => void constructor (formsDiv: PageElement, cfg?: FormsConfig) { this.formsDiv = formsDiv @@ -110,9 +110,10 @@ export class Forms { close (): void { Doc.hide(this.formsDiv) + const closedForm = this.currentForm this.currentForm = undefined this.currentFormID = undefined - if (this.closed) this.closed() + if (this.closed) this.closed(closedForm) } exit () { diff --git a/client/webserver/site/src/js/markets.ts b/client/webserver/site/src/js/markets.ts index 0c55b22a68..48d8b74e89 100644 --- a/client/webserver/site/src/js/markets.ts +++ b/client/webserver/site/src/js/markets.ts @@ -159,7 +159,6 @@ export default class MarketsPage extends BasePage { maxLoaded: (() => void) | null maxOrderUpdateCounter: number market: CurrentMarket - currentForm: HTMLElement openAsset: SupportedAsset currentCreate: SupportedAsset maxEstimateTimer: number | null @@ -215,7 +214,13 @@ export default class MarketsPage extends BasePage { this.recentMatchesSortDirection = -1 // store original title so we can re-append it when updating market value. this.ogTitle = document.title - this.forms = new Forms(page.forms) + this.forms = new Forms(page.forms, { + closed: (closedForm: PageElement | undefined) => { + if (closedForm === page.vDetailPane) { + this.showVerifyForm() + } + } + }) const depthReporters = { click: (x: number) => { this.reportDepthClick(x) }, @@ -421,14 +426,6 @@ export default class MarketsPage extends BasePage { this.forms.close() } - // If the user clicks outside of a form, it should close the page overlay. - bind(page.forms, 'mousedown', (e: MouseEvent) => { - if (Doc.isDisplayed(page.vDetailPane) && !Doc.mouseInElement(e, page.vDetailPane)) return this.showVerifyForm() - if (!Doc.mouseInElement(e, this.currentForm)) { - closePopups() - } - }) - this.keyup = (e: KeyboardEvent) => { if (e.key === 'Escape') { closePopups()