Skip to content

Commit

Permalink
Allow picking the same widget in custom widget gallery (#1327)
Browse files Browse the repository at this point in the history
  • Loading branch information
georgegevoian authored Dec 3, 2024
1 parent ef3e816 commit 40ff38f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
15 changes: 2 additions & 13 deletions app/client/ui/CustomWidgetGallery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions test/nbrowser/CustomWidgets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()=>{
Expand Down

0 comments on commit 40ff38f

Please sign in to comment.