aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/CollectionNoteTakingViewColumn.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2022-08-05 14:55:42 -0400
committerbobzel <zzzman@gmail.com>2022-08-05 14:55:42 -0400
commit51851e8f51f1700757119a09121db20c581a8325 (patch)
tree817120428e36ad0373cec2526b03eb4f9e132542 /src/client/views/collections/CollectionNoteTakingViewColumn.tsx
parentc4cae1a65acd5acaf05c7d64120e422e6adde180 (diff)
fix for deleting columns to properly trigger reactions and avoid index of out bounds
Diffstat (limited to 'src/client/views/collections/CollectionNoteTakingViewColumn.tsx')
-rw-r--r--src/client/views/collections/CollectionNoteTakingViewColumn.tsx12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/client/views/collections/CollectionNoteTakingViewColumn.tsx b/src/client/views/collections/CollectionNoteTakingViewColumn.tsx
index 62d954b9c..624beca96 100644
--- a/src/client/views/collections/CollectionNoteTakingViewColumn.tsx
+++ b/src/client/views/collections/CollectionNoteTakingViewColumn.tsx
@@ -21,6 +21,8 @@ import { ContextMenuProps } from '../ContextMenuItem';
import { EditableView } from '../EditableView';
import { FormattedTextBox } from '../nodes/formattedText/FormattedTextBox';
import './CollectionNoteTakingView.scss';
+import { listSpec } from '../../../fields/Schema';
+import { Cast } from '../../../fields/Types';
const higflyout = require('@hig/flyout');
export const { anchorPoints } = higflyout;
export const Flyout = higflyout.default;
@@ -67,7 +69,7 @@ export class CollectionNoteTakingViewColumn extends React.Component<CSVFieldColu
return this.props.maxColWidth;
}
const i = this.props.columnHeaders.indexOf(this.props.headingObject);
- if (i < 0) {
+ if (i < 0 || i > this.props.columnStartXCoords.length - 1) {
return this.props.maxColWidth;
}
const endColValue = i == this.props.numGroupColumns - 1 ? this.props.PanelWidth : this.props.columnStartXCoords[i + 1];
@@ -147,11 +149,11 @@ export class CollectionNoteTakingViewColumn extends React.Component<CSVFieldColu
@undoBatch
@action
deleteColumn = () => {
- if (this.props.columnHeaders && this.props.headingObject) {
- const index = this.props.columnHeaders.indexOf(this.props.headingObject);
+ const columnHeaders = Cast(this.props.Document.columnHeaders, listSpec(SchemaHeaderField), null);
+ if (columnHeaders && this.props.headingObject) {
+ const index = columnHeaders.indexOf(this.props.headingObject);
this.props.docList.forEach(d => (d[this.props.pivotField] = 'unset'));
- this.props.columnHeaders.splice(index, 1);
- this.props.resizeColumns(this.props.columnHeaders.length);
+ columnHeaders.splice(index, 1);
}
};