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 diff --git a/scripts/build.js b/scripts/build.js index 4b4dc7093..61b818466 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -120,15 +120,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 - } } }; 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.