(core) Refactor disabled summary button logic

Summary:
A project test began failing because of an incompatibility with pointer-events
being disabled. This gets us back to green.

Test Plan: Existing tests.

Reviewers: jordigh

Reviewed By: jordigh

Subscribers: jordigh

Differential Revision: https://phab.getgrist.com/D4325
dependabot/npm_and_yarn/axios-1.7.4
George Gevoian 1 month ago
parent df5080ef38
commit 5c486e686e

@ -328,6 +328,8 @@ export class PageWidgetSelect extends Disposable {
private _isNewTableDisabled = Computed.create(this, this._value.type, (use, type) => !isValidSelection( private _isNewTableDisabled = Computed.create(this, this._value.type, (use, type) => !isValidSelection(
'New Table', type, {isNewPage: this._options.isNewPage, summarize: use(this._value.summarize)})); 'New Table', type, {isNewPage: this._options.isNewPage, summarize: use(this._value.summarize)}));
private _isSummaryDisabled = Computed.create(this, this._value.type, (_use, type) => !isSummaryCompatible(type));
constructor( constructor(
private _value: IWidgetValueObs, private _value: IWidgetValueObs,
private _tables: Observable<TableRec[]>, private _tables: Observable<TableRec[]>,
@ -389,8 +391,9 @@ export class PageWidgetSelect extends Disposable {
cssEntry.cls('-selected', (use) => use(this._value.summarize) && cssEntry.cls('-selected', (use) => use(this._value.summarize) &&
use(this._value.table) === table.id() use(this._value.table) === table.id()
), ),
cssEntry.cls('-disabled', (use) => !isSummaryCompatible(use(this._value.type))), cssEntry.cls('-disabled', this._isSummaryDisabled),
dom.on('click', (ev, el) => this._selectPivot(table.id(), el as HTMLElement)), dom.on('click', (_ev, el) =>
!this._isSummaryDisabled.get() && this._selectPivot(table.id(), el as HTMLElement)),
testId('pivot'), testId('pivot'),
), ),
testId('table'), testId('table'),
@ -572,7 +575,6 @@ const cssEntry = styled('div', `
&-disabled { &-disabled {
color: ${theme.widgetPickerItemDisabledBg}; color: ${theme.widgetPickerItemDisabledBg};
cursor: default; cursor: default;
pointer-events: none;
} }
&-disabled&-selected { &-disabled&-selected {
background-color: inherit; background-color: inherit;

Loading…
Cancel
Save