Fixes bug 'this.valueFormatter is not a function' (#632)

https://grist.slack.com/archives/C069RUP71/p1692034396980779
Bug showed up when deleting a page with the right kinds of
widgets/fields, due to a missing isDisposed check

Bug was found in DateTextBox, but I added the fix to NTextBox which
had an identical bit of code
This commit is contained in:
Janet Vorobyeva 2023-08-22 03:17:01 -04:00 committed by GitHub
parent 963b3ea5df
commit b41fa31dd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -83,7 +83,7 @@ DateTextBox.prototype.buildDom = function(row) {
let value = row[this.field.colId()]; let value = row[this.field.colId()];
return dom('div.field_clip', return dom('div.field_clip',
kd.style('text-align', this.alignment), kd.style('text-align', this.alignment),
kd.text(() => row._isAddRow() ? '' : this.valueFormatter().format(value())) kd.text(() => row._isAddRow() || this.isDisposed() ? '' : this.valueFormatter().format(value()))
); );
}; };

View File

@ -63,7 +63,9 @@ export class NTextBox extends NewAbstractWidget {
return dom('div.field_clip', return dom('div.field_clip',
dom.style('text-align', this.alignment), dom.style('text-align', this.alignment),
dom.cls('text_wrapping', this.wrapping), dom.cls('text_wrapping', this.wrapping),
dom.domComputed((use) => use(row._isAddRow) ? null : makeLinks(use(this.valueFormatter).formatAny(use(value), t))) dom.domComputed((use) => use(row._isAddRow) || this.isDisposed() ?
null :
makeLinks(use(this.valueFormatter).formatAny(use(value), t)))
); );
} }
} }