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

fix(devtools): add shadowDOMTarget property to react-query-devtool #7005

Merged
merged 6 commits into from
Mar 12, 2024

Conversation

michelleoj
Copy link
Contributor

This feature stems from this conversation with @ardeora

The original issue was that if you rendered the devtools in an component that lives in the shadow dom, the styles would be appended to regular DOM's head tag. Since the shadow DOM encapsulates everything, the devtools shows up unstyled. The fix to this is to pass in the shadow root as a target so that goober library will append the styles to the ShadowRoot element.
I've gone ahead and added an example and updated the docs. Let me know if there's anything else I'm missing

Copy link

vercel bot commented Mar 1, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
query ⬜️ Ignored (Inspect) Visit Preview Mar 11, 2024 2:18pm

@michelleoj michelleoj marked this pull request as draft March 1, 2024 17:37
Copy link

codesandbox-ci bot commented Mar 1, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 0b4e792:

Sandbox Source
@tanstack/query-example-angular-basic Configuration
@tanstack/query-example-react-basic-typescript Configuration
@tanstack/query-example-solid-basic-typescript Configuration
@tanstack/query-example-svelte-basic Configuration
@tanstack/query-example-vue-basic Configuration

@michelleoj michelleoj marked this pull request as ready for review March 1, 2024 21:06
Copy link

nx-cloud bot commented Mar 2, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 0b4e792. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


🟥 Failed Commands
nx run-many --targets=test:format,test:sherif,test:knip,test:eslint,test:lib,test:types,test:build,build --parallel=3
✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

@michelleoj
Copy link
Contributor Author

@TkDodo hey there 👋🏾
I would like some eyes on this when you get the chance 😄 🙏🏾

@michelleoj michelleoj changed the title feat(devtools): add shadowDOMTarget property to react-query-devtool fix(devtools): add shadowDOMTarget property to react-query-devtool Mar 5, 2024
michelleoj and others added 2 commits March 5, 2024 10:44
allow devtool to attach styles to the shadow DOM instead of the default head tag of the light DOM
@michelleoj
Copy link
Contributor Author

@ardeora any chance I can get some eyes on this soon please?

@ardeora
Copy link
Contributor

ardeora commented Mar 6, 2024

Apologies for the delay here. I'll be taking a look at this in an hour or two!

Comment on lines 3439 to 3440
const lightStyles = (css) => stylesFactory('light', css)
const darkStyles = (css) => stylesFactory('dark', css)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const lightStyles = (css) => stylesFactory('light', css)
const darkStyles = (css) => stylesFactory('dark', css)
const lightStyles = (css: typeof goober['css']) => stylesFactory('light', css)
const darkStyles = (css: (typeof goober)['css']) => stylesFactory('dark', css)

Types are erroring could you fix the types like so

@ardeora
Copy link
Contributor

ardeora commented Mar 7, 2024

Also could you run pnpm test before committing the changes? You would also notice some formatting errors. If you run pnpm prettier:write it should fix those

@michelleoj michelleoj requested a review from ardeora March 7, 2024 16:43
@michelleoj
Copy link
Contributor Author

@ardeora added your suggestions and now all tests are passing ✅

Copy link
Contributor

@ardeora ardeora left a comment

Choose a reason for hiding this comment

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

These are looking perfect! Thank you for working on this. One other small addition (last one I promise) would be if we can make this feature available in other framework devtools also. You don't need to know Solid, Svelte or Angular. We already have optional props like styleNonce in other framework devtools adapter. We can follow the same convention to add an optional shadowDomTarget prop to all other devtools too. Once that is done, I think we are good to merge.

@michelleoj
Copy link
Contributor Author

@ardeora just added your suggestions and it's ready for another review! 🙏🏾

@codecov-commenter
Copy link

Codecov Report

Merging #7005 (0b4e792) into main (d572279) will decrease coverage by 0.26%.
Report is 58 commits behind head on main.
The diff coverage is 1.61%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #7005      +/-   ##
==========================================
- Coverage   41.29%   41.03%   -0.26%     
==========================================
  Files         180      182       +2     
  Lines        7193     7220      +27     
  Branches     1454     1490      +36     
==========================================
- Hits         2970     2963       -7     
- Misses       3836     3859      +23     
- Partials      387      398      +11     
Components Coverage Δ
@tanstack/angular-query-devtools-experimental ∅ <ø> (∅)
@tanstack/angular-query-experimental 83.90% <100.00%> (+1.61%) ⬆️
@tanstack/eslint-plugin-query 85.11% <ø> (ø)
@tanstack/query-async-storage-persister 49.20% <100.00%> (+0.76%) ⬆️
@tanstack/query-broadcast-client-experimental ∅ <ø> (∅)
@tanstack/query-codemods 0.00% <ø> (ø)
@tanstack/query-core 93.63% <ø> (ø)
@tanstack/query-devtools 3.99% <1.63%> (-0.11%) ⬇️
@tanstack/query-persist-client-core 57.73% <ø> (ø)
@tanstack/query-sync-storage-persister 82.50% <0.00%> (ø)
@tanstack/react-query 93.07% <100.00%> (ø)
@tanstack/react-query-devtools 10.71% <0.00%> (+10.71%) ⬆️
@tanstack/react-query-next-experimental ∅ <ø> (∅)
@tanstack/react-query-persist-client 100.00% <ø> (ø)
@tanstack/solid-query 84.19% <69.69%> (-0.66%) ⬇️
@tanstack/solid-query-devtools ∅ <ø> (∅)
@tanstack/solid-query-persist-client 100.00% <100.00%> (ø)
@tanstack/svelte-query 62.68% <0.00%> (ø)
@tanstack/svelte-query-devtools ∅ <ø> (∅)
@tanstack/svelte-query-persist-client 100.00% <ø> (ø)
@tanstack/vue-query 70.81% <ø> (ø)
@tanstack/vue-query-devtools ∅ <ø> (∅)

@ardeora ardeora merged commit d4def6b into TanStack:main Mar 12, 2024
5 checks passed
@ardeora
Copy link
Contributor

ardeora commented Mar 12, 2024

@michelleoj Thank you so much for working on this! Everything looks great and should be included in the next minor version!

@michelleoj
Copy link
Contributor Author

@ardeora thanks so much for taking the time to review my PR! this is my first time contributing to an open source project so thanks for helping me through it 🎉 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants