Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: 修复列表选取-单选却可以选中多个,溢出隐藏样式错乱 #11478

Merged
merged 4 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions packages/amis-ui/scss/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,9 @@

.#{$ns}#{$component-prefix}-valueLabel {
padding: 0 var(--gap-xs);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ exports[`1. Renderer:Picker base 2`] = `
class="cxd-Picker-valueWrap"
>
<div
class="cxd-OverflowTpl cxd-Picker-value"
class="cxd-Picker-value"
>
<span
class="cxd-Picker-valueIcon"
Expand Down
12 changes: 6 additions & 6 deletions packages/amis/src/renderers/CRUD.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1958,12 +1958,12 @@ export default class CRUD<T extends CRUDProps> extends React.Component<T, any> {
// // newUnSelectedItems.push(...unSelectedItems);
// }

// if (pickerMode && multiple === false && newItems.length > 1) {
// newUnSelectedItems.push.apply(
// newUnSelectedItems,
// newItems.splice(0, newItems.length - 1)
// );
// }
if (pickerMode && multiple === false && newItems.length > 1) {
newUnSelectedItems.push.apply(
newUnSelectedItems,
newItems.splice(0, newItems.length - 1)
);
}
// 用 updateSelectData 导致 CRUD 无限刷新
// store.updateSelectData(newItems, newUnSelectedItems);
store.setSelectedItems(newItems);
Expand Down
57 changes: 30 additions & 27 deletions packages/amis/src/renderers/Form/Picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -544,9 +544,7 @@ export default class PickerControl extends React.PureComponent<
} = this.props;

return (
<OverflowTpl
inline={false}
tooltip={getVariable(item, labelField || 'label')}
<div
key={index}
className={cx(
`${ns}Picker-value`,
Expand Down Expand Up @@ -580,31 +578,36 @@ export default class PickerControl extends React.PureComponent<
×
</span>
)}
<span
className={cx(
`${ns}Picker-valueLabel`,
setThemeClassName({
...this.props,
name: 'pickFontClassName',
id,
themeCss: themeCss || css
})
)}
onClick={e => {
e.stopPropagation();
this.handleItemClick(item);
}}
<OverflowTpl
inline={false}
tooltip={getVariable(item, labelField || 'label')}
>
{labelTpl ? (
<Html html={filter(labelTpl, item)} filterHtml={env.filterHtml} />
) : (
`${
getVariable(item, labelField || 'label') ||
getVariable(item, 'id')
}`
)}
</span>
</OverflowTpl>
<span
className={cx(
`${ns}Picker-valueLabel`,
setThemeClassName({
...this.props,
name: 'pickFontClassName',
id,
themeCss: themeCss || css
})
)}
onClick={e => {
e.stopPropagation();
this.handleItemClick(item);
}}
>
{labelTpl ? (
<Html html={filter(labelTpl, item)} filterHtml={env.filterHtml} />
) : (
`${
getVariable(item, labelField || 'label') ||
getVariable(item, 'id')
}`
)}
</span>
</OverflowTpl>
</div>
);
}

Expand Down
Loading