Skip to content

Commit acb8ee0

Browse files
amcaplanclaude
andcommitted
Fix GraphiQL header responsive behavior
Restores the responsive layout behavior that was lost during the React 18 migration. The original implementation used Polaris Grid with responsive column classes that automatically stacked content vertically on narrow screens. The new CSS Grid implementation was fixed at 7fr/5fr which didn't adapt to screen size. Changes: - Made grid responsive: single column on narrow screens (<1081px), two columns (7fr 5fr) on wide screens - Fixed scopes note alignment: left-aligned when stacked vertically on narrow screens, right-aligned in side column on wide screens - Added top-bar-section-title class to "API version:" label so existing media query can hide it on narrow screens (<1550px) - Cleaned up test type assertions (linter fixes) The header now properly adapts to different screen sizes, matching the original Polaris Grid responsive behavior. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 677dca3 commit acb8ee0

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

packages/graphiql-console/src/components/ApiVersionSelector/ApiVersionSelector.test.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('<ApiVersionSelector />', () => {
3434
const onChange = vi.fn()
3535
renderWithProvider(<ApiVersionSelector versions={defaultVersions} value="2024-10" onChange={onChange} />)
3636

37-
const select = screen.getByLabelText('API version') as HTMLSelectElement
37+
const select = screen.getByLabelText('API version')
3838

3939
expect(select.options).toHaveLength(5)
4040
expect(select.options[0].value).toBe('2024-01')
@@ -48,7 +48,7 @@ describe('<ApiVersionSelector />', () => {
4848
const onChange = vi.fn()
4949
renderWithProvider(<ApiVersionSelector versions={defaultVersions} value="2024-07" onChange={onChange} />)
5050

51-
const select = screen.getByLabelText('API version') as HTMLSelectElement
51+
const select = screen.getByLabelText('API version')
5252
expect(select.value).toBe('2024-07')
5353
})
5454

@@ -68,15 +68,15 @@ describe('<ApiVersionSelector />', () => {
6868
const onChange = vi.fn()
6969
renderWithProvider(<ApiVersionSelector versions={[]} value="" onChange={onChange} />)
7070

71-
const select = screen.getByLabelText('API version') as HTMLSelectElement
71+
const select = screen.getByLabelText('API version')
7272
expect(select.options).toHaveLength(0)
7373
})
7474

7575
test('handles single version', () => {
7676
const onChange = vi.fn()
7777
renderWithProvider(<ApiVersionSelector versions={['2024-10']} value="2024-10" onChange={onChange} />)
7878

79-
const select = screen.getByLabelText('API version') as HTMLSelectElement
79+
const select = screen.getByLabelText('API version')
8080
expect(select.options).toHaveLength(1)
8181
expect(select.options[0].value).toBe('2024-10')
8282
})
@@ -86,7 +86,7 @@ describe('<ApiVersionSelector />', () => {
8686
const onChange = vi.fn()
8787
renderWithProvider(<ApiVersionSelector versions={customVersions} value="v2" onChange={onChange} />)
8888

89-
const select = screen.getByLabelText('API version') as HTMLSelectElement
89+
const select = screen.getByLabelText('API version')
9090
expect(select.options[0].value).toBe('v1')
9191
expect(select.options[1].value).toBe('v2')
9292
expect(select.options[2].value).toBe('v3-beta')

packages/graphiql-console/src/sections/GraphiQL/GraphiQL.module.scss

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
.Header {
1515
display: grid;
16-
grid-template-columns: 7fr 5fr;
16+
grid-template-columns: 1fr; // Single column on narrow screens
1717
align-items: center;
1818
padding: 16px;
1919
border-bottom: 1px solid var(--p-color-border, #e1e3e5);
@@ -29,7 +29,14 @@
2929
}
3030

3131
.RightSection {
32-
justify-self: end;
32+
justify-self: start; // Left-align by default (single column on narrow screens)
33+
}
34+
35+
// Right-align only on wide screens with two-column layout
36+
@media only screen and (min-width: 1081px) {
37+
.RightSection {
38+
justify-self: end;
39+
}
3340
}
3441

3542
.StatusSection {
@@ -106,10 +113,10 @@
106113
}
107114
}
108115

109-
@media only screen and (max-width: 1080px) {
110-
.RightSection {
111-
// Adjust layout for narrower screens
112-
justify-self: start;
116+
// Switch to two-column layout at wider screens
117+
@media only screen and (min-width: 1081px) {
118+
.Header {
119+
grid-template-columns: 7fr 5fr;
113120
}
114121
}
115122

packages/graphiql-console/src/sections/GraphiQL/GraphiQL.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,15 @@ export function GraphiQLSection() {
5858
</div>
5959

6060
<div className={styles.ControlsSection}>
61-
<label htmlFor="api-version-select" style={{marginRight: '8px'}}>
61+
<label htmlFor="api-version-select" className="top-bar-section-title" style={{marginRight: '8px'}}>
6262
API version:
6363
</label>
6464
<div style={{minWidth: '150px'}}>
65-
<ApiVersionSelector versions={config.apiVersions} value={selectedVersion} onChange={handleVersionChange} />
65+
<ApiVersionSelector
66+
versions={config.apiVersions}
67+
value={selectedVersion}
68+
onChange={handleVersionChange}
69+
/>
6670
</div>
6771
</div>
6872

0 commit comments

Comments
 (0)