Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not clear headers when switching between tabs #3552

Merged
merged 11 commits into from
Aug 8, 2024

Conversation

klippx
Copy link
Contributor

@klippx klippx commented Mar 6, 2024

Issue

When switching between tabs, the default header state is lost and replaced with empty string.

Demo of the bug:

Screen.Recording.2024-03-06.at.10.47.10.mov

Codepen to verify/reproduce the issue:

In this example we are using defaultHeaders, and when using multiple tabs, upon reload the headers are cleared when switching tabs.

https://codesandbox.io/p/sandbox/determined-brook-rp683x?file=/package.json:11,23

Note: If you edit the headers before switching tabs, they are not cleared. I am guessing that they are then instead stored in the internal state.

Copy link

changeset-bot bot commented Mar 6, 2024

🦋 Changeset detected

Latest commit: 72a8e6f

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

This PR includes changesets to release 1 package
Name Type
@graphiql/react Patch

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

@acao
Copy link
Member

acao commented Mar 6, 2024

good find, thank you!

Copy link

codecov bot commented Mar 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.60%. Comparing base (c02caf2) to head (72a8e6f).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3552   +/-   ##
=======================================
  Coverage   67.60%   67.60%           
=======================================
  Files         121      121           
  Lines        6968     6968           
  Branches     2247     2247           
=======================================
  Hits         4711     4711           
  Misses       2240     2240           
  Partials       17       17           
Files Coverage Δ
packages/graphiql-react/src/editor/context.tsx 76.22% <100.00%> (ø)
packages/graphiql-react/src/editor/tabs.ts 60.97% <100.00%> (ø)

@klippx
Copy link
Contributor Author

klippx commented Mar 12, 2024

@acao Would it be OK to merge?

@klippx klippx force-pushed the stop-clearing-headers branch 2 times, most recently from 241bb5b to f87c895 Compare March 18, 2024 13:36
@klippx
Copy link
Contributor Author

klippx commented Mar 18, 2024

I pushed another commit since it would just use whatever you have in the editor and not overwrite it, using default headers is a better choice when switching tabs.

Before:

  • Default headers only apply when creating a NEW tab
    After:
  • When switching tab, apply headers || defaultHeaders

@klippx klippx requested a review from acao March 18, 2024 16:10
@klippx
Copy link
Contributor Author

klippx commented Apr 8, 2024

I have two PRs open that initially seem well received, how come we don't move forward and merge if they are perceived as good changes? @acao

@acao
Copy link
Member

acao commented May 11, 2024

@klippx sorry I have been super busy lately and there was something else I needed to check, I cannot remember what held me up last time but I think this should be good to go, perhaps @thomasheyenbrock if you have a chance to look and think this is good to go feel free to merge

@klippx
Copy link
Contributor Author

klippx commented Jun 4, 2024

@thomasheyenbrock can you take a look at this as well? 🙏

@klippx
Copy link
Contributor Author

klippx commented Jun 27, 2024

@dimaMachina 👀 want to take a look?

@dimaMachina dimaMachina changed the base branch from main to 3552 August 7, 2024 23:53
@dimaMachina dimaMachina changed the base branch from 3552 to main August 8, 2024 00:47
dimaMachina added a commit that referenced this pull request Aug 8, 2024
* update create react app example

* Update App.jsx
@dimaMachina dimaMachina merged commit 6a0a5e5 into graphql:main Aug 8, 2024
14 checks passed
@acao acao mentioned this pull request Aug 8, 2024
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.

3 participants