Skip to content

Conversation

@Fil
Copy link
Contributor

@Fil Fil commented Jun 20, 2024

We save the current inspector's expansion state in root.inspectorExpanded, and restore it when we create a new inspector, by passing a div that contains a span with the expected "observablehq--expanded" class.

for now inspectorExpanded is true if defined — this should be revised more thoroughly when we fix observablehq/inspector#12

closes #1458

Copy link
Member

@mbostock mbostock left a comment

Choose a reason for hiding this comment

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

We should avoid using delete and instead represent inspector state consistently by initializing it when the root node is attached (i.e., in define).

Also, we should handle the multiple displayed items case better — we should err towards collapsing rather than expanding.

(I think technically we could avoid storing any additional state on the root because it could be part of the display closure, but that’s just an optimization I guess.)

@Fil
Copy link
Contributor Author

Fil commented Jul 3, 2024

my test.md bench:


```js
const value = view(Inputs.button("reset"));
```

```js
const foo = {name: "foo", value};
const bar = {name: "bar", more: {value}};
```

```js
foo
```

```js
if (Math.random() > 0.5) display(foo);
display(bar);
```

```js
Math.random() > 0.5 ? foo : bar
```

Copy link
Member

@mbostock mbostock left a comment

Choose a reason for hiding this comment

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

🚀

@mbostock mbostock merged commit ee49233 into main Jul 30, 2024
@mbostock mbostock deleted the fil/expand-inspector branch July 30, 2024 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Maintain deep expanded state. Keep the inspector open on update

3 participants