Skip to content

Commit b3b8a57

Browse files
committed
Remove comments from new sessions. Closes #623
1 parent 850c1e0 commit b3b8a57

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

packages/graphql-playground-react/src/components/Playground/QueryEditor.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ export class QueryEditor extends React.PureComponent<Props & ReduxProps, {}> {
184184
componentWillReceiveProps(nextProps) {
185185
if (this.props.sessionId !== nextProps.sessionId) {
186186
this.closeCompletion()
187+
this.editor.focus()
187188
}
188189
}
189190

packages/graphql-playground-react/src/state/sessions/reducers.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,9 @@ const reducer = handleActions(
367367
.set('sessionCount', newState.sessions.size)
368368
},
369369
NEW_SESSION: (state, { payload: { reuseHeaders, endpoint } }) => {
370-
let session = makeSession(endpoint || state.sessions.first().endpoint)
370+
let session = makeSession(
371+
endpoint || state.sessions.first().endpoint,
372+
).set('query', '')
371373
if (reuseHeaders) {
372374
const selectedSessionId = getSelectedSessionId(state)
373375
const currentSession = state.sessions.get(selectedSessionId)
@@ -521,10 +523,9 @@ function closeTab(state, sessionId) {
521523
// if there is only one session, delete it and replace it by a new one
522524
// and keep the endpoint & headers of the last one
523525
if (length === 1) {
524-
const newSession = makeSession(session.endpoint).set(
525-
'headers',
526-
session.headers,
527-
)
526+
const newSession = makeSession(session.endpoint)
527+
.set('headers', session.headers)
528+
.set('query', '')
528529
newState = newState.set('selectedSessionId', newSession.id)
529530
return newState.setIn(['sessions', newSession.id], newSession)
530531
}

0 commit comments

Comments
 (0)