Skip to content
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

expand the inspector if its previous version was expanded #1475

Merged
merged 7 commits into from
Jul 30, 2024

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.)

src/client/main.js Outdated Show resolved Hide resolved
src/client/main.js Outdated Show resolved Hide resolved
src/client/inspect.js Outdated Show resolved Hide resolved
@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
4 checks passed
@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
2 participants