Skip to content

Commit

Permalink
PresetSearchBox: Add warning and different cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
jvaclavik committed Feb 20, 2025
1 parent 93cd065 commit 8c13f10
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
ListSubheader,
MenuItem,
Select,
Tooltip,
} from '@mui/material';
import SearchIcon from '@mui/icons-material/Search';
import styled from '@emotion/styled';
Expand Down Expand Up @@ -190,30 +191,40 @@ export const PresetSearchBox = ({ value, setValue, options }: Props) => {

return (
<>
<Select
disabled={!enabled}
MenuProps={{
autoFocus: false,
slotProps: { paper: getPaperMaxHeight(selectRef) },
}}
value={value}
onChange={onChange}
onClose={() => setSearchText('')}
renderValue={() =>
renderOption(options.find((o) => o.presetKey === value))
}
variant="outlined"
fullWidth
displayEmpty
ref={selectRef}
<Tooltip
title={enabled ? '' : t('editdialog.preset_select.change_type_warning')}
arrow
>
<SearchRow onChange={(e) => setSearchText(e.target.value)} />
{displayedOptions.map((option) => (
<MenuItem key={option} component="li" value={option}>
{renderOption(options.find((o) => o.presetKey === option))}
</MenuItem>
))}
</Select>
<Select
disabled={!enabled}
sx={{
'.Mui-disabled': {
cursor: 'not-allowed !important',
},
}}
MenuProps={{
autoFocus: false,
slotProps: { paper: getPaperMaxHeight(selectRef) },
}}
value={value}
onChange={onChange}
onClose={() => setSearchText('')}
renderValue={() =>
renderOption(options.find((o) => o.presetKey === value))
}
variant="outlined"
fullWidth
displayEmpty
ref={selectRef}
>
<SearchRow onChange={(e) => setSearchText(e.target.value)} />
{displayedOptions.map((option) => (
<MenuItem key={option} component="li" value={option}>
{renderOption(options.find((o) => o.presetKey === option))}
</MenuItem>
))}
</Select>
</Tooltip>
{!enabled && (
// TODO we may warn users that this is not usual operation, if this becomes an issue
<Box ml={1}>
Expand Down
1 change: 1 addition & 0 deletions src/locales/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ export default {
'editdialog.preset_select.placeholder': 'Vyberte typ',
'editdialog.preset_select.search_placeholder': 'Zadejte hledaný výraz...',
'editdialog.preset_select.edit_button': 'Upravit',
'editdialog.preset_select.change_type_warning': 'Změna typu není obvyklá operace. Pokud tato změna dává smysl, můžete změnit typ tlačítkem vpravo.',

'tags.name': 'Název',
'tags.description': 'Popis',
Expand Down
2 changes: 2 additions & 0 deletions src/locales/vocabulary.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ export default {
'editdialog.preset_select.placeholder': 'Select the type',
'editdialog.preset_select.search_placeholder': 'Type to search...',
'editdialog.preset_select.edit_button': 'Edit',
'editdialog.preset_select.change_type_warning':
'Changing the type is not usual operation. Consider if this change makes sense and use button on the right to enable.',

'tags.name': 'Name',
'tags.description': 'Description',
Expand Down

0 comments on commit 8c13f10

Please sign in to comment.