Commit b3f5459
authored
fix: Re-running ui code initially rendering the old document (#1017)
This fixes a bug where re-running code causes the old document to be
rendered first. This can cause initial mounting with old props for
document trees that don't change between runs which can cause problems
with components that rely on an initial prop value only.
This also fixes an issue where the old panels are shown until new
panels/document is fetched. Now, it will show loading spinners on those
panels instead. If the new document (re-assigned to the same variable in
Python) has a new tree structure, then the old panels will be closed and
new panels opened. If the document has the same tree, then the new
panels will replace the old panels.
This Python example shows a slow loading component. Run the code, then
change the props (I commented out the `format_` prop) and re-run. The
existing panel should turn into a loading spinner and then load without
the formatting rules.
```py
from deephaven import ui
import deephaven.plot.express as dx
import time
@ui.component
def my_t():
time.sleep(2)
return ui.table(
dx.data.stocks().update("SymColor=Sym==`FISH` ? `positive` : `salmon`"),
hidden_columns=["SymColor"],
format_=[
ui.TableFormat(value="0.00%"),
ui.TableFormat(cols="Timestamp", value="E, dd MMM yyyy HH:mm:ss z"),
ui.TableFormat(cols="Size", color="info", if_="Size < 10"),
ui.TableFormat(cols="Size", color="notice", if_="Size > 100"),
ui.TableFormat(cols=["Sym", "Exchange"], alignment="center"),
ui.TableFormat(
cols=["Sym", "Exchange"], background_color="negative", if_="Sym=`CAT`"
),
ui.TableFormat(if_="Sym=`DOG`", color="oklab(0.6 -0.3 -0.25)"),
ui.TableFormat(cols="Sym", color="SymColor"),
],
)
t = my_t()
```1 parent c25f578 commit b3f5459
File tree
3 files changed
+40
-16
lines changed- plugins/ui/src/js/src
- layout
- widget
3 files changed
+40
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
| 79 | + | |
86 | 80 | | |
87 | 81 | | |
88 | 82 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
11 | 17 | | |
12 | 18 | | |
13 | 19 | | |
| |||
186 | 192 | | |
187 | 193 | | |
188 | 194 | | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
189 | 204 | | |
190 | 205 | | |
191 | 206 | | |
| |||
224 | 239 | | |
225 | 240 | | |
226 | 241 | | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
| 242 | + | |
232 | 243 | | |
233 | 244 | | |
234 | 245 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| |||
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
67 | 79 | | |
68 | 80 | | |
69 | 81 | | |
| |||
224 | 236 | | |
225 | 237 | | |
226 | 238 | | |
227 | | - | |
228 | | - | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
229 | 245 | | |
230 | 246 | | |
231 | 247 | | |
| |||
339 | 355 | | |
340 | 356 | | |
341 | 357 | | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
342 | 361 | | |
343 | 362 | | |
344 | 363 | | |
345 | 364 | | |
346 | | - | |
| 365 | + | |
347 | 366 | | |
348 | 367 | | |
349 | 368 | | |
| |||
0 commit comments