This commit is contained in:
seb
2026-10-05 12:40:02 +02:00
parent 8c5419c89e
commit 358d34ecab
3 changed files with 44 additions and 41 deletions

View File

@@ -110,14 +110,19 @@ export default class TextInput extends Component {
const { input: _unusedInput, ...restSlotProps } = (slotProps || {}); const { input: _unusedInput, ...restSlotProps } = (slotProps || {});
const hasLabelProps = Boolean(label || InputLabelProps || slotProps?.inputLabel);
const mergedSlotProps = { const mergedSlotProps = {
...restSlotProps, ...restSlotProps,
...(resolvedInputProps ? { input: resolvedInputProps } : {}), ...(resolvedInputProps ? { input: resolvedInputProps } : {}),
...(hasLabelProps
? {
inputLabel: { inputLabel: {
...(label ? { shrink: true } : {}), ...(label ? { shrink: true } : {}),
...InputLabelProps, ...InputLabelProps,
...slotProps?.inputLabel, ...slotProps?.inputLabel,
}, },
}
: {}),
htmlInput, htmlInput,
}; };

View File

@@ -12,7 +12,7 @@ import List from '@mui/material/List';
import ListItemAvatar from '@mui/material/ListItemAvatar'; import ListItemAvatar from '@mui/material/ListItemAvatar';
import ListItemButton from '@mui/material/ListItemButton'; import ListItemButton from '@mui/material/ListItemButton';
import ListItemText from '@mui/material/ListItemText'; import ListItemText from '@mui/material/ListItemText';
import TextField from '@mui/material/TextField'; import TextInput from '../TextInput';
import Typography from '@mui/material/Typography'; import Typography from '@mui/material/Typography';
import Chip from '@mui/material/Chip'; import Chip from '@mui/material/Chip';
import Alert from '@mui/material/Alert'; import Alert from '@mui/material/Alert';
@@ -255,8 +255,7 @@ export default class ArticleSearch extends PureComponent {
renderTrigger() { renderTrigger() {
const { const {
placeholder = 'Artikel suchen…', placeholder = '',
label,
value = null, value = null,
disabled = false, disabled = false,
size = 'small', size = 'small',
@@ -270,13 +269,10 @@ export default class ArticleSearch extends PureComponent {
: ''; : '';
return ( return (
<TextField <TextInput
fullWidth fullWidth
type="search"
autoComplete="off"
size={size} size={size}
label={label} placeholder={placeholder || ''}
placeholder={placeholder || 'Artikel suchen (EAN, Artikelnr., Name, Barcode)…'}
value={displayValue} value={displayValue}
disabled={disabled} disabled={disabled}
onClick={() => { onClick={() => {
@@ -288,15 +284,15 @@ export default class ArticleSearch extends PureComponent {
if (!disabled) this.handleOpenDialog(); if (!disabled) this.handleOpenDialog();
} }
}} }}
readOnly
slotProps={{ slotProps={{
htmlInput: {
autoCapitalize: 'off',
autoCorrect: 'off',
},
input: { input: {
notched: false,
readOnly: true, readOnly: true,
sx: { sx: {
height: 40, '& .MuiOutlinedInput-notchedOutline legend': {
display: 'none',
},
cursor: disabled ? 'default' : 'pointer', cursor: disabled ? 'default' : 'pointer',
textOverflow: 'ellipsis', textOverflow: 'ellipsis',
'& input': { '& input': {
@@ -306,7 +302,7 @@ export default class ArticleSearch extends PureComponent {
}, },
startAdornment: ( startAdornment: (
<InputAdornment position="start"> <InputAdornment position="start">
<SearchIcon color="action" /> <SearchIcon fontSize="small" color="action" />
</InputAdornment> </InputAdornment>
), ),
endAdornment: value ? ( endAdornment: value ? (
@@ -321,7 +317,7 @@ export default class ArticleSearch extends PureComponent {
}} }}
edge="end" edge="end"
> >
<CloseIcon sx={{ fontSize: 18 }} /> <CloseIcon sx={{ fontSize: 16 }} />
</IconButton> </IconButton>
</InputAdornment> </InputAdornment>
) : null, ) : null,
@@ -337,7 +333,7 @@ export default class ArticleSearch extends PureComponent {
renderListContent() { renderListContent() {
const { const {
placeholder = 'Artikel nach SKU, Name oder EAN suchen…', placeholder = '',
autoFocus = true, autoFocus = true,
actionLabel = 'Auswählen', actionLabel = 'Auswählen',
} = this.props; } = this.props;
@@ -376,12 +372,12 @@ export default class ArticleSearch extends PureComponent {
)} )}
<Box ref={this.headerRef} sx={{ flexShrink: 0 }}> <Box ref={this.headerRef} sx={{ flexShrink: 0 }}>
<TextField <TextInput
autoFocus={autoFocus} autoFocus={autoFocus}
fullWidth fullWidth
type="search" size="small"
autoComplete="off" readOnly={false}
placeholder={placeholder || 'Artikel suchen (EAN, Artikelnr., Name, Barcode)…'} placeholder={placeholder || ''}
value={query} value={query}
onChange={(e) => { onChange={(e) => {
const val = e.target.value; const val = e.target.value;
@@ -389,35 +385,41 @@ export default class ArticleSearch extends PureComponent {
this.runQuery(val, 0); this.runQuery(val, 0);
}} }}
onKeyDown={(e) => { onKeyDown={(e) => {
if (e.key === 'Enter' && results.length > 0) { if (e.key === 'Escape' && query) {
e.preventDefault();
this.setState({ query: '', offset: 0 });
this.runQuery('', 0);
} else if (e.key === 'Enter' && results.length > 0) {
e.preventDefault(); e.preventDefault();
this.handleSelectArticle(results[0]); this.handleSelectArticle(results[0]);
} }
}} }}
disabled={Boolean(busySku)} disabled={Boolean(busySku)}
slotProps={{ slotProps={{
htmlInput: {
autoCapitalize: 'off',
autoCorrect: 'off',
},
input: { input: {
sx: { height: 40 }, notched: false,
sx: {
'& .MuiOutlinedInput-notchedOutline legend': {
display: 'none',
},
},
startAdornment: ( startAdornment: (
<InputAdornment position="start"> <InputAdornment position="start">
<SearchIcon color="action" /> <SearchIcon fontSize="small" color="action" />
</InputAdornment> </InputAdornment>
), ),
endAdornment: query ? ( endAdornment: query ? (
<InputAdornment position="end"> <InputAdornment position="end">
<IconButton <IconButton
size="small" size="small"
aria-label="Eingabe leeren"
onClick={() => { onClick={() => {
this.setState({ query: '', offset: 0 }); this.setState({ query: '', offset: 0 });
this.runQuery('', 0); this.runQuery('', 0);
}} }}
edge="end" edge="end"
> >
<CloseIcon sx={{ fontSize: 18 }} /> <CloseIcon sx={{ fontSize: 16 }} />
</IconButton> </IconButton>
</InputAdornment> </InputAdornment>
) : null, ) : null,
@@ -815,11 +817,10 @@ export default class ArticleSearch extends PureComponent {
if (params.InputProps) { if (params.InputProps) {
return ( return (
<TextField <TextInput
{...params} {...params}
autoFocus={autoFocus} autoFocus={autoFocus}
label={label} placeholder={placeholder || ''}
placeholder={placeholder}
InputProps={{ InputProps={{
...params.InputProps, ...params.InputProps,
startAdornment, startAdornment,
@@ -830,11 +831,10 @@ export default class ArticleSearch extends PureComponent {
} }
return ( return (
<TextField <TextInput
{...params} {...params}
autoFocus={autoFocus} autoFocus={autoFocus}
label={label} placeholder={placeholder || ''}
placeholder={placeholder}
slotProps={{ slotProps={{
...params.slotProps, ...params.slotProps,
input: { input: {

View File

@@ -50,7 +50,6 @@ export default class ArticleSearchDialog extends PureComponent {
const { open, onClose, line } = this.props; const { open, onClose, line } = this.props;
const { assigningSku, error } = this.state; const { assigningSku, error } = this.state;
const rawSku = line?.sku != null ? String(line.sku).trim() : ''; const rawSku = line?.sku != null ? String(line.sku).trim() : '';
const initialQuery = line?.name?.trim() || line?.sku?.trim() || '';
return ( return (
<Dialog <Dialog
@@ -131,7 +130,6 @@ export default class ArticleSearchDialog extends PureComponent {
<ArticleSearch <ArticleSearch
mode="list" mode="list"
autoFocus autoFocus
initialQuery={initialQuery}
allowParent={false} allowParent={false}
busySku={assigningSku} busySku={assigningSku}
actionLabel={assigningSku ? 'Zuordnen…' : 'Zuordnen'} actionLabel={assigningSku ? 'Zuordnen…' : 'Zuordnen'}