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

fix: When all items except the disabled item in the left panel of tra… #2574

Merged
merged 2 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/semi-foundation/transfer/transfer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 14 additions & 3 deletions packages/semi-ui/transfer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,17 @@ class Transfer extends BaseComponent<TransferProps, TransferState> {
// 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}`);

Expand All @@ -418,7 +428,7 @@ class Transfer extends BaseComponent<TransferProps, TransferState> {
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
};
Expand Down Expand Up @@ -638,12 +648,13 @@ class Transfer extends BaseComponent<TransferProps, TransferState> {
}
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);
Expand Down