From 0c9af1c3d586bc8902ab7db4396fa8bcfa0bde46 Mon Sep 17 00:00:00 2001 From: George Gevoian Date: Thu, 21 Nov 2024 23:43:21 -0500 Subject: [PATCH 1/3] Relax disabling save in CustomWidgetGallery --- app/client/ui/CustomWidgetGallery.ts | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/app/client/ui/CustomWidgetGallery.ts b/app/client/ui/CustomWidgetGallery.ts index 2f22de1859..0bfb50070f 100644 --- a/app/client/ui/CustomWidgetGallery.ts +++ b/app/client/ui/CustomWidgetGallery.ts @@ -102,21 +102,10 @@ class CustomWidgetGallery extends Disposable { } }); - this._saveDisabled = Computed.create(this, use => { - const selectedWidgetId = use(this._selectedWidgetId); - if (!selectedWidgetId) { return true; } - if (!this._section) { return false; } - - const savedWidgetId = use(this._savedWidgetId); - if (selectedWidgetId === CUSTOM_URL_WIDGET_ID) { - return ( - use(this._savedWidgetId) === CUSTOM_URL_WIDGET_ID && - use(this._customUrl) === use(this._section.customDef.url) - ); - } else { - return selectedWidgetId === savedWidgetId; - } - }); + this._saveDisabled = Computed.create( + this, + (use) => !use(this._selectedWidgetId) + ); this._initializeWidgets().catch(reportError); From bda84fbc35a0520e23230c7c9bd3d97166a486d1 Mon Sep 17 00:00:00 2001 From: George Gevoian Date: Tue, 26 Nov 2024 16:06:51 -0500 Subject: [PATCH 2/3] Add test --- test/nbrowser/CustomWidgets.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/nbrowser/CustomWidgets.ts b/test/nbrowser/CustomWidgets.ts index bcd4aeaad1..53d5c122e4 100644 --- a/test/nbrowser/CustomWidgets.ts +++ b/test/nbrowser/CustomWidgets.ts @@ -674,6 +674,13 @@ describe('CustomWidgets', function () { (done: any) => (window as any).gristApp?.topAppModel.testReloadWidgets().then(done).catch(done) || done() ); }); + + it("allows picking the same widget", async () => { + await gu.setCustomWidget(/W1/); + assert.equal(await gu.getCustomWidgetName(), "W1"); + await gu.setCustomWidget(/W1/); + assert.equal(await gu.getCustomWidgetName(), "W1"); + }); }); describe('gristApiSupport', async ()=>{ From c858b88934e6f816850954619aa322b2261c5155 Mon Sep 17 00:00:00 2001 From: George Gevoian Date: Mon, 2 Dec 2024 20:18:51 -0500 Subject: [PATCH 3/3] Make code more explicit --- app/client/ui/CustomWidgetGallery.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/client/ui/CustomWidgetGallery.ts b/app/client/ui/CustomWidgetGallery.ts index 0bfb50070f..62f30fa003 100644 --- a/app/client/ui/CustomWidgetGallery.ts +++ b/app/client/ui/CustomWidgetGallery.ts @@ -102,10 +102,10 @@ class CustomWidgetGallery extends Disposable { } }); - this._saveDisabled = Computed.create( - this, - (use) => !use(this._selectedWidgetId) - ); + this._saveDisabled = Computed.create(this, (use) => { + const selectedWidgetId = use(this._selectedWidgetId); + return selectedWidgetId === null; + }); this._initializeWidgets().catch(reportError);