Skip to content

Commit ce97e88

Browse files
authored
Merge pull request #366 from Wain-PC/on_model_change_action
Added `action` argument to `onModelChange` prop function call
2 parents ab45dc6 + ba5e902 commit ce97e88

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/model/Model.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export class Model {
115115
/** @internal */
116116
private _idMap: Record<string, Node>;
117117
/** @internal */
118-
private _changeListener?: () => void;
118+
private _changeListener?: (action: Action) => void;
119119
/** @internal */
120120
private _root?: RowNode;
121121
/** @internal */
@@ -150,7 +150,7 @@ export class Model {
150150
}
151151

152152
/** @internal */
153-
_setChangeListener(listener: (() => void) | undefined) {
153+
_setChangeListener(listener: ((action: Action) => void) | undefined) {
154154
this._changeListener = listener;
155155
}
156156

@@ -402,7 +402,7 @@ export class Model {
402402
this._updateIdMap();
403403

404404
if (this._changeListener !== undefined) {
405-
this._changeListener();
405+
this._changeListener(action);
406406
}
407407

408408
return returnVal;

src/view/Layout.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export interface ILayoutProps {
6060
tabSetNode: TabSetNode | BorderNode,
6161
renderValues: ITabSetRenderValues, // change the values in this object as required
6262
) => void;
63-
onModelChange?: (model: Model) => void;
63+
onModelChange?: (model: Model, action: Action) => void;
6464
onExternalDrag?: (event: React.DragEvent<HTMLDivElement>) => undefined | {
6565
dragText: string,
6666
json: any,
@@ -316,10 +316,10 @@ export class Layout extends React.Component<ILayoutProps, ILayoutState> {
316316
}
317317

318318
/** @internal */
319-
onModelChange = () => {
319+
onModelChange = (action: Action) => {
320320
this.forceUpdate();
321321
if (this.props.onModelChange) {
322-
this.props.onModelChange(this.props.model);
322+
this.props.onModelChange(this.props.model, action);
323323
}
324324
};
325325

0 commit comments

Comments
 (0)