Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow picking the same widget in custom widget gallery #1327

Merged
merged 3 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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