fix(web): keep user picker label inline

This commit is contained in:
2026-06-17 22:57:49 +08:00
parent 045d522ea0
commit f96d3a2ea4
3 changed files with 52 additions and 15 deletions

View File

@@ -38,6 +38,7 @@ type UserTransferPickerProps = {
data?: Record<string, unknown>;
name?: string;
label?: string | false;
required?: boolean;
className?: string;
style?: CSSProperties;
onChange?: (value: string | string[] | undefined) => void;
@@ -437,9 +438,11 @@ export class UserTransferPicker extends Component<UserTransferPickerProps, UserT
const {
className,
disabled,
label,
readOnly,
placeholder = '请选择',
clearable = true,
required,
style,
} = this.props;
const {
@@ -462,8 +465,11 @@ export class UserTransferPicker extends Component<UserTransferPickerProps, UserT
const selectedFiltered = filterOptions(draft, selectedSearch);
const displayText = displayTextFor(labels, placeholder);
const fullTitle = labels.map((item) => item.label).join(', ');
const controlClassName = [
const fieldClassName = [
className,
'eip4-user-transfer-field',
].filter(Boolean).join(' ');
const controlClassName = [
'eip4-user-transfer-control',
disabled || readOnly ? 'is-disabled' : '',
labels.length ? '' : 'is-empty',
@@ -471,21 +477,28 @@ export class UserTransferPicker extends Component<UserTransferPickerProps, UserT
return (
<>
<div
className={controlClassName}
onClick={this.openDialog}
role="button"
style={style}
tabIndex={disabled || readOnly ? -1 : 0}
title={fullTitle || undefined}
>
<span className="eip4-user-transfer-text">{displayText}</span>
{clearable && labels.length > 0 && !disabled && !readOnly ? (
<button type="button" onClick={this.clearValue} aria-label="清空">
×
</button>
<div className={fieldClassName} style={style}>
{label !== false && label ? (
<label className="eip4-user-transfer-label">
{label}
{required ? <span className="eip4-user-transfer-star">*</span> : null}
</label>
) : null}
<span className="eip4-user-transfer-icon" aria-hidden="true" />
<div
className={controlClassName}
onClick={this.openDialog}
role="button"
tabIndex={disabled || readOnly ? -1 : 0}
title={fullTitle || undefined}
>
<span className="eip4-user-transfer-text">{displayText}</span>
{clearable && labels.length > 0 && !disabled && !readOnly ? (
<button type="button" onClick={this.clearValue} aria-label="清空">
×
</button>
) : null}
<span className="eip4-user-transfer-icon" aria-hidden="true" />
</div>
</div>
{open ? (