Commit 4fd4f6d
authored
Right now, `SlideOverPanel` can be opened/closed by passing
`<SlideOverPanel open={isPanelOpen}` or by conditionally rendering it
with `isPanelOpen && <SlideOverPanel`. This is problematic because when
there are two ways to open/close something, it means there are multiple
ways we need to account for when thinking about animations and deferring
rendering the contents.
This PR removes the `open` prop. `SlideOverPanel` now _must_ be rendered
conditionally with `&&` in JSX. This required an update to how the
contents are deferred on mount, but otherwise behaviour is preserved.
I was pushed towards the `isOpen &&` API due to a practical problem in
Dashboards, but I also think it's a reasonable choice overall.
## Rationale
Consider:
```
<Container>
<SlideOverPanel ...
<PreviewWidget /...
</Container>
```
Imagine that the container has a panel, and a preview which both take up
half the screen and slide in from opposite sides. The container takes up
the full screen, and is shown over some background content. It's offset
against the main sidebar.
- the container _must_ exist to account for the sidebar, and to
correctly split space between the panel and preview
- the container must take up the whole screen, which means it prevents
clicks on content underneath
- I need to hide/show the container, panel, preview when users click on
buttons in the UI
- the panel and preview both have a slight animation to make it less
jarring when they open-close
```
+-------------------------+
| +---------++---------+ |
| | || | |
| | || | |
| | Panel || Preview | |
| | || | |
| | || | |
| | || | |
| +---------++---------+ |
| |
| Container |
| |
+-------------------------+
```
There are two major problems.
1. How should I go about hiding/showing the container? The container
blocks the content underneath. When the panel and the preview close, how
do I hide the container? I could either make it "invisible" by turning
off opacity and pointer events, or use `display: none`. The former is
messy, and error prone. It's easy to accidentally leave this in, and
cause issues with clicks. The latter is difficult, how do I coordinate
setting `display: none` vs. the panel and preview when they slide? This
is the case in the Widget Builder.
2. What if I need to remount the `Container` for some reason? e.g., the
container might have some kind of context, or something else that needs
to be remounted or re-rendered that might cause a re-mount of the panel.
In that case, deferring the content of the panel won't work, since it's
relying on the `open` prop state _changing_, but on initial mount there
is no change. This is also the case in the Widget Builder. It's not
possible to have a deferral mechanism that works both on mount and on
prop change!
If the API is `isOpen &&` these problems are solved. I can just
mount/unmount the entire tree, and everything works as expected. Since
there is only one way to show/hide the panel, I can use one deferral
method, and I don't need explanations in the doc for how to handle
animations and deferral.
In short, controlling mounting/unmounting is a lot easier than
controlling an `open` prop because I don't have to worry about keeping
surrounding components in the DOM just to make animations and deferred
rendering work.
1 parent 5d638b1 commit 4fd4f6d
File tree
6 files changed
+151
-136
lines changed- static/app
- components
- core/slideOverPanel
- globalDrawer
- stories/playground
- views
- dashboards/widgetBuilder/components
- preprod/buildDetails/main/insights
6 files changed
+151
-136
lines changedLines changed: 40 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
38 | 42 | | |
39 | 43 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
69 | 74 | | |
70 | 75 | | |
71 | 76 | | |
72 | 77 | | |
73 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
Lines changed: 34 additions & 48 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | 33 | | |
38 | 34 | | |
39 | 35 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | 36 | | |
45 | 37 | | |
46 | 38 | | |
| |||
53 | 45 | | |
54 | 46 | | |
55 | 47 | | |
56 | | - | |
57 | 48 | | |
58 | 49 | | |
59 | | - | |
60 | 50 | | |
61 | 51 | | |
62 | 52 | | |
63 | 53 | | |
64 | 54 | | |
65 | 55 | | |
66 | 56 | | |
67 | | - | |
68 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
69 | 60 | | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
82 | 77 | | |
83 | 78 | | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
98 | 83 | | |
99 | 84 | | |
100 | | - | |
| 85 | + | |
101 | 86 | | |
102 | 87 | | |
103 | 88 | | |
104 | 89 | | |
105 | 90 | | |
106 | 91 | | |
107 | | - | |
| 92 | + | |
108 | 93 | | |
109 | 94 | | |
110 | 95 | | |
| |||
116 | 101 | | |
117 | 102 | | |
118 | 103 | | |
119 | | - | |
| 104 | + | |
120 | 105 | | |
121 | 106 | | |
122 | 107 | | |
123 | 108 | | |
124 | 109 | | |
125 | 110 | | |
126 | 111 | | |
127 | | - | |
128 | | - | |
| 112 | + | |
| 113 | + | |
129 | 114 | | |
130 | 115 | | |
131 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
132 | 119 | | |
133 | | - | |
| 120 | + | |
134 | 121 | | |
135 | 122 | | |
136 | 123 | | |
137 | 124 | | |
138 | | - | |
139 | | - | |
| 125 | + | |
140 | 126 | | |
141 | 127 | | |
142 | 128 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
79 | 78 | | |
80 | 79 | | |
81 | 80 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
22 | 25 | | |
23 | 26 | | |
24 | 27 | | |
| |||
34 | 37 | | |
35 | 38 | | |
36 | 39 | | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
46 | 53 | | |
47 | 54 | | |
48 | 55 | | |
| |||
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
212 | | - | |
213 | 212 | | |
214 | 213 | | |
215 | 214 | | |
| |||
0 commit comments