Skip to content

Commit cc93ffc

Browse files
committed
change auto_reset_expanded to enabled by default
1 parent af13591 commit cc93ffc

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

examples/demo/src/apps/default_expand.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ impl Show for DefaultExpandExample {
126126

127127
let response = JsonTree::new(self.title(), &self.value)
128128
.default_expand((&self.state_default_expand).into())
129-
.auto_reset_expanded(true)
130129
.show(ui);
131130

132131
if ui.button("Reset expanded").clicked() {

examples/demo/src/apps/search.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ impl Show for SearchExample {
3838

3939
let response = JsonTree::new(self.title(), &self.value)
4040
.default_expand(DefaultExpand::SearchResults(&self.search_input))
41-
.auto_reset_expanded(true)
4241
.show(ui);
4342

4443
if ui.button("Reset expanded").clicked() {

src/tree.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl<T: ToJsonTreeValue> Default for JsonTreeConfig<'_, T> {
1919
Self {
2020
style: Default::default(),
2121
default_expand: Default::default(),
22-
auto_reset_expanded: false,
22+
auto_reset_expanded: true,
2323
renderer: Default::default(),
2424
}
2525
}
@@ -56,7 +56,9 @@ impl<'a, T: ToJsonTreeValue> JsonTree<'a, T> {
5656
self
5757
}
5858

59-
/// Automatically reset expanded arrays/objects to respect the [`DefaultExpand`] setting when it changes.
59+
/// If enabled, automatically reset expanded arrays/objects to respect the [`DefaultExpand`] setting when it changes for this tree Id.
60+
/// This can still be performed manually via [`JsonTreeResponse::reset_expanded`](crate::JsonTreeResponse::reset_expanded) after rendering the tree.
61+
/// Defaults to enabled.
6062
pub fn auto_reset_expanded(mut self, auto_reset_expanded: bool) -> Self {
6163
self.config.auto_reset_expanded = auto_reset_expanded;
6264
self

tests/json_tree_test.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ fn json_tree_reset_expanded() {
541541
CentralPanel::default().show(ctx, |ui| {
542542
JsonTree::new(id, &value)
543543
.default_expand(DefaultExpand::All)
544+
.auto_reset_expanded(false)
544545
.style(JsonTreeStyle::new().abbreviate_root(true))
545546
.on_render(|_, render_ctx| {
546547
actual.push(render_ctx.into());
@@ -561,6 +562,7 @@ fn json_tree_reset_expanded() {
561562
CentralPanel::default().show(ctx, |ui| {
562563
JsonTree::new(id, &value)
563564
.default_expand(DefaultExpand::None)
565+
.auto_reset_expanded(false)
564566
.style(JsonTreeStyle::new().abbreviate_root(true))
565567
.on_render(|_, render_ctx| {
566568
actual.push(render_ctx.into());
@@ -581,6 +583,7 @@ fn json_tree_reset_expanded() {
581583
CentralPanel::default().show(ctx, |ui| {
582584
JsonTree::new(id, &value)
583585
.default_expand(DefaultExpand::None)
586+
.auto_reset_expanded(false)
584587
.style(JsonTreeStyle::new().abbreviate_root(true))
585588
.on_render(|_, render_ctx| {
586589
actual.push(render_ctx.into());

0 commit comments

Comments
 (0)