-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(perf): Do not render contents of closed panels (#70286)
Right now, when a `SlideOverPanel` is collapsed, its contents still exist in the DOM. This has a whole bunch of downsides: 1. React has to render stuff inside, which is pointless since it's invisible 2. When writing mocks, we have to assert on elements that might exist in the panel even if its closed This is very annoying! This PR changes it up to use `AnimatePresence` which lets us use a `!collapsed &` condition and _not_ render the panel's contents in the DOM if it's collapsed. Also clarified some variables names while I'm at it, and removed some unused CSS.
- Loading branch information
Showing
2 changed files
with
53 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {render, screen} from 'sentry-test/reactTestingLibrary'; | ||
|
||
import DetailPanel from 'sentry/views/starfish/components/detailPanel'; | ||
|
||
describe('DetailPanel', function () { | ||
it('renders toolbar and inner content', function () { | ||
render(<DetailPanel detailKey={'true'}>Content</DetailPanel>); | ||
|
||
expect(screen.getByRole('button', {name: 'Dock to the bottom'})).toBeInTheDocument(); | ||
expect(screen.getByRole('button', {name: 'Dock to the right'})).toBeInTheDocument(); | ||
expect(screen.getByRole('button', {name: 'Close Details'})).toBeInTheDocument(); | ||
|
||
expect(screen.getByText('Content')).toBeInTheDocument(); | ||
}); | ||
|
||
it('does not render content when closed', function () { | ||
render(<DetailPanel detailKey={undefined}>Content</DetailPanel>); | ||
|
||
expect(screen.queryByRole('button', {name: 'Close Details'})).not.toBeInTheDocument(); | ||
expect(screen.queryByText('Content')).not.toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters