From 40ff38fa5247aea974c8550d51a99af142485757 Mon Sep 17 00:00:00 2001 From: George Gevoian <85144792+georgegevoian@users.noreply.github.com> Date: Mon, 2 Dec 2024 20:34:45 -0500 Subject: [PATCH] Allow picking the same widget in custom widget gallery (#1327) --- app/client/ui/CustomWidgetGallery.ts | 15 ++------------- test/nbrowser/CustomWidgets.ts | 7 +++++++ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/app/client/ui/CustomWidgetGallery.ts b/app/client/ui/CustomWidgetGallery.ts index 2f22de1859..62f30fa003 100644 --- a/app/client/ui/CustomWidgetGallery.ts +++ b/app/client/ui/CustomWidgetGallery.ts @@ -102,20 +102,9 @@ class CustomWidgetGallery extends Disposable { } }); - this._saveDisabled = Computed.create(this, use => { + 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; - } + return selectedWidgetId === null; }); this._initializeWidgets().catch(reportError); 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 ()=>{