Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Save keyMap to the local storage
  • Loading branch information
semanser committed Nov 29, 2019
1 parent 812cd00 commit 3ab07be
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/graphiql/src/components/GraphiQL.js
Expand Up @@ -150,7 +150,7 @@ export class GraphiQL extends React.Component {
DEFAULT_DOC_EXPLORER_WIDTH,
isWaitingForResponse: false,
subscription: null,
keyMap: props.keyMap,
keyMap: this._storage.get('keyMap') || props.keyMap,
...queryFacts,
};

Expand Down Expand Up @@ -269,6 +269,7 @@ export class GraphiQL extends React.Component {
this._storage.set('docExplorerWidth', this.state.docExplorerWidth);
this._storage.set('docExplorerOpen', this.state.docExplorerOpen);
this._storage.set('historyPaneOpen', this.state.historyPaneOpen);
this._storage.set('keyMap', this.state.keyMap);
}

render() {
Expand Down Expand Up @@ -923,9 +924,12 @@ export class GraphiQL extends React.Component {
};

handleToggleKeyMap = () => {
const updatedKeyMap = this.state.keyMap === 'sublime' ? 'vim' : 'sublime';
this.setState({
keyMap: this.state.keyMap === 'sublime' ? 'vim' : 'sublime'
keyMap: updatedKeyMap
});

this._storage.set('keyMap', updatedKeyMap);
};

handleResizeStart = downEvent => {
Expand Down

0 comments on commit 3ab07be

Please sign in to comment.