From da6ae608f1bc4bda5fb9891f2e4f2d7c829b3b4c Mon Sep 17 00:00:00 2001 From: Tao Cumplido Date: Mon, 28 Nov 2022 17:55:12 +0100 Subject: [PATCH 1/3] only emit a tree's selection change event when the selection has actually changed (#1030) --- src/components/tree/tree.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/tree/tree.ts b/src/components/tree/tree.ts index 37d5accd4..b355511d6 100644 --- a/src/components/tree/tree.ts +++ b/src/components/tree/tree.ts @@ -177,6 +177,8 @@ export default class SlTree extends ShoelaceElement { } selectItem(selectedItem: SlTreeItem) { + const previousSelection = [...this.selectedItems]; + if (this.selection === 'multiple') { selectedItem.selected = !selectedItem.selected; if (selectedItem.lazy) { @@ -192,7 +194,11 @@ export default class SlTree extends ShoelaceElement { selectedItem.expanded = !selectedItem.expanded; } - this.emit('sl-selection-change', { detail: { selection: this.selectedItems } }); + const nextSelection = this.selectedItems; + + if (nextSelection.some(item => !previousSelection.includes(item))) { + this.emit('sl-selection-change', { detail: { selection: nextSelection } }); + } } // Returns the list of tree items that are selected in the tree. From 83b73e823d2ae59664a7303e80990b40b00fca99 Mon Sep 17 00:00:00 2001 From: Cory LaViska Date: Mon, 28 Nov 2022 11:56:13 -0500 Subject: [PATCH 2/3] update changelog; #1030 --- docs/resources/changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/resources/changelog.md b/docs/resources/changelog.md index 18500c91f..c0571c7ea 100644 --- a/docs/resources/changelog.md +++ b/docs/resources/changelog.md @@ -13,6 +13,7 @@ New versions of Shoelace are released as-needed and generally occur when a criti - Fixed a bug in `` that caused containing dialogs, drawers, etc. to close when pressing Escape while focused [#1024](https://github.com/shoelace-style/shoelace/issues/1024) - Fixed a bug in `` that allowed lazy nodes to be incorrectly selected [#1023](https://github.com/shoelace-style/shoelace/pull/1023) - Fixed a typing bug in `` [#1026](https://github.com/shoelace-style/shoelace/pull/1026) +- Fixed a bug in `` where `sl-selection-change` was emitted when the selection didn't change [#1030](https://github.com/shoelace-style/shoelace/pull/1030) - Updated Floating UI to 1.0.7 to fix a bug that prevented `hoist` from working correctly in `` after a recent update [#1024](https://github.com/shoelace-style/shoelace/issues/1024) ## 2.0.0-beta.84 From 4ac948321378b172f4bbc7b9dd7209bd00c5a97f Mon Sep 17 00:00:00 2001 From: Cory LaViska Date: Mon, 28 Nov 2022 16:06:35 -0500 Subject: [PATCH 3/3] remove unused config --- scripts/build.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/scripts/build.js b/scripts/build.js index 6cc7f7fea..0a41fac35 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -121,15 +121,6 @@ fs.mkdirSync(outdir, { recursive: true }); routes: { '/dist': './dist' } - }, - socket: { - socketIoClientConfig: { - // Configure socketIO to retry forever when disconnected to enable the auto-reattach timeout below to work - reconnectionAttempts: Infinity, - reconnectionDelay: 500, - reconnectionDelayMax: 500, - timeout: 1000 - } } };