Skip to content

Commit

Permalink
Use default query on adding new tab
Browse files Browse the repository at this point in the history
  • Loading branch information
cimdalli committed Oct 28, 2023
1 parent 6d36412 commit 544cbe1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/graphiql-react/src/editor/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -366,14 +366,20 @@ export function EditorContextProvider(props: EditorContextProviderProps) {
headerEditor,
responseEditor,
});
const { onTabChange, defaultHeaders, children } = props;
const { onTabChange, defaultHeaders, defaultQuery, children } = props;

const addTab = useCallback<EditorContextType['addTab']>(() => {
setTabState(current => {
// Make sure the current tab stores the latest values
const updatedValues = synchronizeActiveTabValues(current);
const updated = {
tabs: [...updatedValues.tabs, createTab({ headers: defaultHeaders })],
tabs: [
...updatedValues.tabs,
createTab({
headers: defaultHeaders,
query: defaultQuery ?? DEFAULT_QUERY,
}),
],
activeTabIndex: updatedValues.tabs.length,
};
storeTabs(updated);
Expand Down

0 comments on commit 544cbe1

Please sign in to comment.