-
-
Notifications
You must be signed in to change notification settings - Fork 19
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(overlay): Do not modify body styles on injection #615
Conversation
Fixes #613. We used to add `overflow: auto` on injection, no matter what. This is bad for a few reasons: 1. Our default is already the closed state, so we should not do anything on initial injection 2. We don't store or know the original value of this style we are touching, which may cause breakage 3. It causes hydration issues as highlighted in #613 This PR injects a special class into the DOM using [adoptedStyleSheets API](https://developer.mozilla.org/en-US/docs/Web/API/Document/adoptedStyleSheets) on injection and just toggles this class on open/close.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #615 +/- ##
==========================================
+ Coverage 31.32% 31.33% +0.01%
==========================================
Files 92 92
Lines 5421 5422 +1
Branches 99 99
==========================================
+ Hits 1698 1699 +1
Misses 3723 3723 ☔ View full report in Codecov by Sentry. |
@@ -217,10 +218,10 @@ export default function App({ | |||
useEffect(() => { | |||
if (!isOpen) { | |||
spotlightEventTarget.dispatchEvent(new CustomEvent('closed')); | |||
document.body.style.overflow = 'auto'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We just need to remove this, right?
But I think it's good to have another stylesheet layer added with classname
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing wouldn't fix as we need a way of undoing our "hidden" override when a user toggles Spotlight closed
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and publish to npm yourself or [setup this action to publish automatically](https://github.com/changesets/action#with-publishing). If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @spotlightjs/[email protected] ### Minor Changes - Add Sentry SDK for monitoring ([#620](#620)) ### Patch Changes - Fix Spotlight UI not using correct sidecar URL w/ non-default port ([#618](#618)) - Don't alter body styles at all ([#615](#615)) - Make in-browser direct Sentry SDK link more graceful at the start ([#614](#614)) - Updated dependencies \[[`7ea060b832a67cf39676d7fbdbbecb02bb2830e3`](7ea060b), [`705595349718abb1dea188efc92ab02a4268f323`](7055953), [`76bc48618812f260b8788b83926fa36fbd9ade35`](76bc486), [`4716ddeda0e52289b0f9bc9889ffcf957a69d1a8`](4716dde), [`a77a8698bd892762b149b555058eb345fac2c686`](a77a869), [`6240009c99fa4699f25325e356b32dc8849e3b92`](6240009)]: - @spotlightjs/[email protected] - @spotlightjs/[email protected] ## @spotlightjs/[email protected] ### Patch Changes - Updated dependencies \[[`455f6966d0602af38fd0835627d11dea03b88362`](455f696), [`4716ddeda0e52289b0f9bc9889ffcf957a69d1a8`](4716dde), [`6240009c99fa4699f25325e356b32dc8849e3b92`](6240009), [`f0bb9a98b4df7ce49c9fd73a093dc7b2005305b9`](f0bb9a9)]: - @spotlightjs/[email protected] ## @spotlightjs/[email protected] ### Patch Changes - Updated dependencies \[[`7ea060b832a67cf39676d7fbdbbecb02bb2830e3`](7ea060b), [`705595349718abb1dea188efc92ab02a4268f323`](7055953), [`76bc48618812f260b8788b83926fa36fbd9ade35`](76bc486), [`4716ddeda0e52289b0f9bc9889ffcf957a69d1a8`](4716dde), [`a77a8698bd892762b149b555058eb345fac2c686`](a77a869), [`6240009c99fa4699f25325e356b32dc8849e3b92`](6240009)]: - @spotlightjs/[email protected] - @spotlightjs/[email protected] ## @spotlightjs/[email protected] ### Patch Changes - Use a maintained version of ReactJsonViewer ([#611](#611)) - - Added a createTab helper function ([#606](#606)) - Added Trace root transaction name in Trace detail header ([#612](#612)) - Don't alter body styles at all ([#615](#615)) - Make in-browser direct Sentry SDK link more graceful at the start ([#614](#614)) ## @spotlightjs/[email protected] ### Patch Changes - Fix sidecar package build, export all from dist with types ([#616](#616)) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Fixes #613.
We used to add
overflow: auto
on injection, no matter what. This is bad for a few reasons:This PR injects a special class into the DOM using adoptedStyleSheets API on injection and just toggles this class on open/close.