From b017a2acd47c8889819b5310b63c17ce4eebbe1b Mon Sep 17 00:00:00 2001 From: "zhangyumei.0319" Date: Thu, 14 Nov 2024 19:55:13 +0800 Subject: [PATCH 1/2] fix: When all items except the disabled item in the left panel of transfer are selected, the operation button should display Cancel all selections --- packages/semi-foundation/transfer/transfer.scss | 1 + packages/semi-ui/transfer/index.tsx | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/semi-foundation/transfer/transfer.scss b/packages/semi-foundation/transfer/transfer.scss index 13c7f08ec3..e40ec11fed 100644 --- a/packages/semi-foundation/transfer/transfer.scss +++ b/packages/semi-foundation/transfer/transfer.scss @@ -53,6 +53,7 @@ $module: #{$prefix}-transfer; margin-bottom: $spacing-transfer_header-marginBottom; margin-left: $spacing-transfer_header-marginLeft; color: $color-transfer_header-text; + flex-shrink: 0; &-all { font-weight: $font-transfer_header_all-fontWeight; diff --git a/packages/semi-ui/transfer/index.tsx b/packages/semi-ui/transfer/index.tsx index 46dc2f79d6..1aa26e6d33 100644 --- a/packages/semi-ui/transfer/index.tsx +++ b/packages/semi-ui/transfer/index.tsx @@ -409,7 +409,17 @@ class Transfer extends BaseComponent { // For example, the filtered data on the left is 1, 3, 4; // The selected option is 1,2,3,4, it is true // The selected option is 2,3,4, then it is false - const leftContainesNotInSelected = Boolean(filterData.find(f => !selectedItems.has(f.key))); + let filterDataAllDisabled = true; + const leftContainesNotInSelected = Boolean(filterData.find(f => { + if (f.disabled) { + return false; + } else { + if (filterDataAllDisabled) { + filterDataAllDisabled = false; + } + return !selectedItems.has(f.key); + } + })); const totalText = totalToken.replace('${total}', `${showNumber}`); @@ -418,7 +428,7 @@ class Transfer extends BaseComponent { allContent: leftContainesNotInSelected ? locale.selectAll : locale.clearSelectAll, onAllClick: () => this.foundation.handleAll(leftContainesNotInSelected), type: 'left', - showButton: type !== strings.TYPE_TREE_TO_LIST, + showButton: type !== strings.TYPE_TREE_TO_LIST && !filterDataAllDisabled, num: showNumber, allChecked: !leftContainesNotInSelected }; @@ -638,12 +648,13 @@ class Transfer extends BaseComponent { } const selectedToken = locale.selected; const selectedText = selectedToken.replace('${total}', `${selectedData.length}`); + const hasValidSelected = selectedData.findIndex(item => !item.disabled) !== -1; const headerConfig = { totalContent: selectedText, allContent: locale.clear, onAllClick: () => this.foundation.handleClear(), type: 'right', - showButton: Boolean(selectedData.length), + showButton: Boolean(selectedData.length) && hasValidSelected, num: selectedData.length, }; const headerCom = this.renderHeader(headerConfig); From bc18822fc43055d9e956815ea75ac65d3732f455 Mon Sep 17 00:00:00 2001 From: "zhangyumei.0319" Date: Mon, 18 Nov 2024 15:05:15 +0800 Subject: [PATCH 2/2] chore: Fix variable typo --- packages/semi-ui/transfer/index.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/semi-ui/transfer/index.tsx b/packages/semi-ui/transfer/index.tsx index 1aa26e6d33..aeec88ed23 100644 --- a/packages/semi-ui/transfer/index.tsx +++ b/packages/semi-ui/transfer/index.tsx @@ -410,7 +410,7 @@ class Transfer extends BaseComponent { // The selected option is 1,2,3,4, it is true // The selected option is 2,3,4, then it is false let filterDataAllDisabled = true; - const leftContainesNotInSelected = Boolean(filterData.find(f => { + const leftContainsNotInSelected = Boolean(filterData.find(f => { if (f.disabled) { return false; } else { @@ -425,12 +425,12 @@ class Transfer extends BaseComponent { const headerConfig: HeaderConfig = { totalContent: totalText, - allContent: leftContainesNotInSelected ? locale.selectAll : locale.clearSelectAll, - onAllClick: () => this.foundation.handleAll(leftContainesNotInSelected), + allContent: leftContainsNotInSelected ? locale.selectAll : locale.clearSelectAll, + onAllClick: () => this.foundation.handleAll(leftContainsNotInSelected), type: 'left', showButton: type !== strings.TYPE_TREE_TO_LIST && !filterDataAllDisabled, num: showNumber, - allChecked: !leftContainesNotInSelected + allChecked: !leftContainsNotInSelected }; const inputCom = this.renderFilter(locale); const headerCom = this.renderHeader(headerConfig); @@ -482,13 +482,13 @@ class Transfer extends BaseComponent { filterData, sourceData: data, propsDataSource: dataSource, - allChecked: !leftContainesNotInSelected, + allChecked: !leftContainsNotInSelected, showNumber, inputValue, selectedItems, value: values, onSelect: this.foundation.handleSelect.bind(this.foundation), - onAllClick: () => this.foundation.handleAll(leftContainesNotInSelected), + onAllClick: () => this.foundation.handleAll(leftContainsNotInSelected), onSearch: this.onInputChange, onSelectOrRemove: (item: ResolvedDataItem) => this.onSelectOrRemove(item), };