Skip to content

v6: Promote variables/headers footer into a tab strip#4337

Draft
trevor-scheer wants to merge 5 commits into
graphiql-6from
trevor/pr-35
Draft

v6: Promote variables/headers footer into a tab strip#4337
trevor-scheer wants to merge 5 commits into
graphiql-6from
trevor/pr-35

Conversation

@trevor-scheer
Copy link
Copy Markdown
Contributor

Summary

The variables/headers footer below the operation editor is replaced by a VarHeadersStrip component with two tabs: Variables and Headers. The existing JSON editors are reused under their respective tabs. A right-aligned validity hint on the Variables tab shows how many variables are defined and whether they parse as valid JSON.

Test plan

  • Switch between Variables and Headers tabs; each shows the correct editor
  • Edit variables JSON; the validity hint updates to reflect the count and valid/invalid state
  • Empty variables editor shows no hint
  • Existing variables and headers content is preserved when switching tabs
  • The strip is vertically resizable using the drag handle above it
  • The show/hide toggle collapses and restores the strip
  • Active tab persists across page reload (stored in localStorage)

Refs: #4219

Replaces the old toggle UI below the query editor with `VarHeadersStrip`,
a segmented control with Variables and Headers tabs. The Variables tab shows
an inline hint with the variable count and JSON validity status.

The previous `.graphiql-editor-tool` DOM structure is replaced; only CSS
variable names remain part of the public API.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 6, 2026

🦋 Changeset detected

Latest commit: 58f3c91

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@graphiql/react Major
graphiql Major
@graphiql/plugin-code-exporter Major
@graphiql/plugin-doc-explorer Major
@graphiql/plugin-explorer Major
@graphiql/plugin-history Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

- Remove stale `'snippets'` guard from `getInitialVarTab()` — not a valid
  `VarTab` since the type was narrowed to `'variables' | 'headers'`
- Restore `defaultEditorToolsVisibility="variables"|"headers"` behaviour via
  `useLayoutEffect` + `setVarTab` in `GraphiQLInterface`
- Update `GraphiQL.spec.tsx` to query the new `[aria-label="Variables and Headers"]`
  section and the radio inputs instead of the old per-tab section labels
- Clear localStorage in Cypress `beforeEach` so `varTab` (now persisted to
  storage) doesn't bleed between specs
- Fix `commands.ts` headers editor selector: after the tab switch, only one
  editor is in the DOM so use `.eq(0)` instead of `.eq(1)`
- Fix `tabs.cy.ts` headers textarea selector for the same reason
- Fix `graphql-ws.cy.ts` Monaco editor count: now 3 (query + variables/headers
  (one at a time) + response) instead of 4
- Format with `oxfmt`
…sStrip

- Don't dispose Monaco models on editor unmount in `VariablesEditor` and
  `RequestHeadersEditor` — models persist across var/headers tab switches so
  content is preserved when the editor remounts
- Null-guard `editor.getModel()` in `useChangeHandler` before calling
  `onDidChangeContent` (disposed editors return null from `getModel()`)
- Fall back to direct Monaco model API in `setEditorValues` and
  `synchronizeActiveTabValues` when the editor is disposed (e.g. when
  varTab='headers' and the variables editor is unmounted)
- Guard `prettifyEditors` against disposed editors with `getModel()` check
- Fix `.graphiql-editor-tool` CSS to be a flex column so `VarHeadersStrip`'s
  `flex: 1` actually fills the container — previously the editor had 0 height
  which caused Monaco to render 0 lines (no squiggly decorations, no content)
The deprecated-arguments test was racing against the 200ms debounced search:
`useState(() => getSearchResults(''))` initializes with all ~104 schema
entities when the schema is already loaded. `cy.dataCy('doc-explorer-option').first()`
grabbed the wrong entry before the debounce could narrow to the 1 correct result.

Fix: add `.should('have.length', 1)` between `.type('hasArgs')` and
`.first().children().first().click()` so Cypress retries until the debounce fires.

Also narrow `cy.clearLocalStorage()` to `cy.clearLocalStorage(/^graphiql:varTab$/)` so
only the varTab key is cleared between tests — the stated intent — rather than all localStorage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant