Skip to content

Commit

Permalink
EditDialog: fix TagsEditor for empty tags/coordsFeature (#683)
Browse files Browse the repository at this point in the history
  • Loading branch information
zbycz authored Oct 15, 2024
1 parent 57819b1 commit 5c20b38
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import AddIcon from '@mui/icons-material/Add';
import { majorKeys } from '../MajorKeysEditor';
import { isString } from '../../../../helpers';
import { t, Translation } from '../../../../../services/intl';
import { useEditContext } from '../../EditContext';
import { TagsEntries, useEditContext } from '../../EditContext';
import { useEditDialogContext } from '../../../helpers/EditDialogContext';
import { KeyInput } from './KeyInput';
import { ValueInput } from './ValueInput';
Expand Down Expand Up @@ -68,10 +68,14 @@ const TagsEditorInfo = () => (
</tr>
);

const lastKeyAndValueSet = (tagsEntries: TagsEntries) => {
const [lastKey, lastValue] = tagsEntries[tagsEntries.length - 1];
return lastKey && lastValue;
};

const AddButton = () => {
const { tagsEntries, setTagsEntries } = useEditContext().tags;
const [lastKey, lastValue] = tagsEntries[tagsEntries.length - 1];
const active = tagsEntries.length === 0 || (lastKey && lastValue);
const active = tagsEntries.length === 0 || lastKeyAndValueSet(tagsEntries);

return (
<tr>
Expand Down

0 comments on commit 5c20b38

Please sign in to comment.