Skip to content

Commit

Permalink
Merge branch 'master' into renovate/ts-jest-24.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas ERNY committed Apr 20, 2019
2 parents bb00aff + ce36601 commit e99fee1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"husky": "^1.3.1",
"jest": "^24.3.1",
"jest-canvas-mock": "^2.0.0-beta.1",
"prettier": "1.16.4",
"prettier": "1.17.0",
"pretty-quick": "^1.10.0",
"react": "16.x",
"react-dom": "16.x",
Expand Down
3 changes: 3 additions & 0 deletions src/GojsDiagram.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ describe('<GojsDiagram />', () => {

const myDiagramId = 'myDiagramId';

const defaultSelectedNodeKey = 'Beta';

let diagram: Diagram;
let wrapper;
let modelChangeCallback;
Expand Down Expand Up @@ -127,6 +129,7 @@ describe('<GojsDiagram />', () => {
newdata.key = keyIndex;
return newdata;
}}
defaultSelectedNode={defaultSelectedNodeKey}
/>,
{ attachTo: dom }
);
Expand Down
7 changes: 6 additions & 1 deletion src/GojsDiagram.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface GojsDiagramProps<N extends BaseNodeModel, L extends LinkModel>
makeUniqueLinkKeyFunction?: () => go.Key;
copyNodeDataFunction?: (data: ObjectData, model: go.Model) => ObjectData;
updateDiagramProps?: (myDiagram: Diagram) => void;
defaultSelectedNode?: string;
}

export interface GojsModel extends go.Model {
Expand Down Expand Up @@ -82,7 +83,7 @@ class GojsDiagram<N extends BaseNodeModel, L extends LinkModel> extends React.Pu
this.myDiagram.commitTransaction('updated');
}
init() {
const { createDiagram, diagramId, onModelChange } = this.props;
const { createDiagram, diagramId, onModelChange, defaultSelectedNode } = this.props;
this.myDiagram = createDiagram(diagramId);
if (onModelChange) {
this.myDiagram.addModelChangedListener(this.modelChangedHandler);
Expand All @@ -102,6 +103,10 @@ class GojsDiagram<N extends BaseNodeModel, L extends LinkModel> extends React.Pu
makeUniqueLinkKeyFunction: this.props.makeUniqueLinkKeyFunction || null,
copyNodeDataFunction: this.props.copyNodeDataFunction || null
});

if (defaultSelectedNode) {
this.myDiagram.select(this.myDiagram.findNodeForKey(defaultSelectedNode));
}
}
render() {
return <div id={this.props.diagramId} className={this.props.className} />;
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2801,9 +2801,9 @@ prelude-ls@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"

prettier@1.16.4:
version "1.16.4"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.16.4.tgz#73e37e73e018ad2db9c76742e2647e21790c9717"
prettier@1.17.0:
version "1.17.0"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.17.0.tgz#53b303676eed22cc14a9f0cec09b477b3026c008"

pretty-format@^24.3.1:
version "24.3.1"
Expand Down

0 comments on commit e99fee1

Please sign in to comment.