Skip to content

Conversation

@josephfusco
Copy link
Member

What does this implement/fix? Explain your changes.

This pull request enhances the tab state management for the WPGraphQL settings page by integrating query arguments with a fallback to localStorage. This ensures that tab states are sharable via URLs while maintaining backward compatibility with users' existing localStorage preferences.

Does this close any currently open issues?

closes #3142

Testing

  1. Navigate to a tab using a URL with the tab query argument and verify the correct tab opens.
  2. Clear the query argument, navigate to different tabs, and ensure the last active tab is remembered across page loads.
  3. Click on different tabs and verify that both the URL and localStorage are updated correctly.
2024-05-29.at.17.09.37.-.Yellow.Finch.webm

@coveralls
Copy link

coveralls commented May 29, 2024

Coverage Status

coverage: 84.347% (-0.02%) from 84.37%
when pulling c597d7d on feat/3142-settings-tab-link
into 5d3cd82 on develop.

@josephfusco josephfusco requested a review from jasonbahl May 29, 2024 21:57
@jasonbahl
Copy link
Collaborator

@josephfusco we should add an e2e test for this.

The Codeception tests don't run JavaScript in the client, so we'd need to add a PlayWright test, similar to this one: https://github.com/wp-graphql/wp-graphql/pull/3137/files#diff-9d15a2c2ea09662e39dfeb06f50ed190a3c6319ba2d0f3a637527a98fa6f7fb3

Copy link
Collaborator

@jasonbahl jasonbahl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add test(s)

var queryTab = urlParams.get('tab');

//if url has section id as hash then set it as active or override the current local storage value
if (window.location.hash) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@josephfusco perhaps we should maintain this mechanism of using the hash?

the deeplinking is technically already working. If I hover the tabs I can see the #name-of-tab in the url and if I copy the link and visit it, the link works 🤔

I do think the improvments to store in localStorage and push to the url are good, but maybe instead of using tab query param, we can continue to use the hash in case anyone already is making use of linking with the hash

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, great call out. I've updated this PR to use the existing hash functionality

@qlty-cloud-legacy
Copy link

Code Climate has analyzed commit c597d7d and detected 0 issues on this pull request.

View more on Code Climate.

@jasonbahl jasonbahl merged commit 18a22f5 into develop May 30, 2024
@jasonbahl jasonbahl mentioned this pull request Jun 5, 2024
@justlevine justlevine deleted the feat/3142-settings-tab-link branch December 28, 2024 22:39
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.

Deep Linking for WPGraphQL Settings pages

4 participants