-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[graphiql] Refreshing page can erroneously create new tabs #2825
Comments
I would propose passing If that's accepted I'll prepare a merge request |
Oh I just found #2145 adding that would probably also fix my issue |
Fixing the behavior of the |
Here is a simple reproduction of this bug: it only requires setting a |
a clue - this bug goes away when it seems that the tab state context on init mismatches the previous state, and assumes the query parameters or user input of headers are indicating a new tab state update: i have a "fix", however I can't get the e2e suite to re-create this bug! |
Solves #2825, an old bug where new tabs were created on every refresh the bug occurred when: 1. `shouldPersistHeaders` is not set to true 2. `headers` or `defaultHeaders` are provided as props 3. the user refreshes the browser
Solves #2825, an old bug where new tabs were created on every refresh the bug occurred when: 1. `shouldPersistHeaders` is not set to true 2. `headers` or `defaultHeaders` are provided as props 3. the user refreshes the browser
if any users want to confirm the fix, try this canary release:
|
@markedwards can you try these patch versions and confirm the fix works for you, at least for |
Solves #2825, an old bug where new tabs were created on every refresh the bug occurred when: 1. `shouldPersistHeaders` is not set to true 2. `headers` or `defaultHeaders` are provided as props 3. the user refreshes the browser
Sorry, haven't got to it yet. I'll try to test today or tomorrow. It seems to be fixed on https://deploy-preview-3377--graphiql-test.netlify.app |
@acao Does not seem to be fixed when using https://unpkg.com/graphiql@3.0.5-canary-f6e35dd1.0/graphiql.js. |
@markedwards the fix has already been released, can you try it with the latest? I was able to reproduce the bug and eliminate the bug with this release |
Okay, well I can no longer reproduce multiple Oddly, I no longer reproduce the multiple tab issue, even on https://unpkg.com/graphiql@3.0.0/graphiql.min.js. Did the behavior of 3.0.0 change? |
hmm, it seems the issue wasn't completely resolved then. 3.0.0 was released a while ago so the behavior shouldn't have changed. it would've been the last graphiql patch version that resolves the issue, 3.0.5 |
@markedwards what happens when you try deleting all the tabs and history, and then try to reproduce the bug? or better yet, if you clear local storage state and try reproducing it? lingering local storage states may cause this issue to seem like it's still an issue. I cannot seem to get a tab to appear on refresh anymore |
Wiping local storage doesn't seem to have any effect, the behavior is exactly the same. I see no difference between 3.0.0 and 3.0.5, they both spawn empty tabs on refresh. I can sometimes get more than one to spawn on both versions actually, but I'm not exactly sure when this happens. I think it has something to do with persistent headers. |
@markedwards this example clears it up: No new tabs are created when https://codesandbox.io/s/graphiql-bug-2825-kxx2j7?file=/index.html But when you disable this value, and refresh, you get new headers. So the issue is not fixed. My bugfix works for the first case, but for the second case, causes a mismatch, because headers are set statically, but not persisted. |
I think the best option is to remove also this issue is not apparent when you use if you want to set default headers for every query, and make them a transparent choice, set the headers in your |
I’m reproducing this without any settings being overridden at all. I’m not setting headers, or changing any default setting. |
Even I am running into the same issue without any settings being changed. |
GraphiQL interface resets the value of "shouldPersistHeaders" to `false` upon refreshing the browser (see graphql/graphiql#3369). As a result, on a second refresh, the header value is lost. The fix reads the value of the `localStorage` key `graphiql:shouldPersistHeaders` and passes that value to the `shouldPersistHeaders` prop of the GraphiQL component. This change has an unwanted side-effect of creating new tabs if: - The user has provided a header value - The user refreshes the browser See graphql/graphiql#2825 for more details. However, we don't observe the "new tabs" behavior when the UI refreshes automatically on "exo yolo" or "exo dev", so this is still an overall improvement for the typical user of Exograph. When the mentioned issues are fixed, we should be able to revert this change.
GraphiQL interface resets the value of "shouldPersistHeaders" to `false` upon refreshing the browser (see graphql/graphiql#3369). As a result, on a second refresh, the header value is lost. The fix reads the value of the `localStorage` key `graphiql:shouldPersistHeaders` and passes that value to the `shouldPersistHeaders` prop of the GraphiQL component. This change has an unwanted side-effect of creating new tabs if: - The user has provided a header value - The user refreshes the browser See graphql/graphiql#2825 for more details. However, we don't observe the "new tabs" behavior when the UI refreshes automatically on "exo yolo" or "exo dev", so this is still an overall improvement for the typical user of Exograph. When the mentioned issues are fixed, we should be able to revert this change. Fixes #997 997
Is there an existing issue for this?
Current Behavior
If you set initial headers and disable
shouldPersistHeaders
graphiql creates a new tab although it shouldn'tTabs aren't stored with headers, but the getDefaultTabState function doesn't know about the
shouldPersistHeaders
flag. So it compares a stored tab without headers with the headers that are passed to graphiql and decides to create a new tabExpected Behavior
Refreshing the page shouldn't create a new tab
Steps To Reproduce
and
shouldPersistHeaders: false,
The text was updated successfully, but these errors were encountered: