Skip to content

Commit

Permalink
EditDialog: Fix major keys bug (#909)
Browse files Browse the repository at this point in the history
  • Loading branch information
jvaclavik authored Jan 28, 2025
1 parent 38d142e commit 1ab64ac
Showing 1 changed file with 23 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react';
import { Button, TextField, Typography, Box } from '@mui/material';
import { Button, TextField, Typography, Box, Switch } from '@mui/material';
import { t } from '../../../../../services/intl';
import {
getNextWikimediaCommonsIndex,
Expand Down Expand Up @@ -140,24 +140,31 @@ export const MajorKeysEditor = () => {
}
}, [focusTag]); // eslint-disable-line react-hooks/exhaustive-deps

const getInputEleement = (k: string) => {
if (!data.keys?.includes(k)) return null;
switch (k) {
case 'opening_hours':
return <OpeningHoursEditor />;

default:
return (
<TextFieldWithCharacterCount
label={data.names[k]}
k={k}
autoFocus={focusTag === k}
onChange={(e) => {
setTag(e.target.name, e.target.value);
}}
value={tags[k] ?? ''}
/>
);
}
};

return (
<Box mb={3}>
{activeMajorKeys.map((k) => (
<div key={k}>
{k === 'opening_hours' ? (
<OpeningHoursEditor />
) : (
<TextFieldWithCharacterCount
label={data.names[k]}
k={k}
autoFocus={focusTag === k}
onChange={(e) => {
setTag(e.target.name, e.target.value);
}}
value={tags[k] ?? ''}
/>
)}
</div>
<div key={k}>{getInputEleement(k)}</div>
))}
{!!inactiveMajorKeys.length && (
<>
Expand Down

0 comments on commit 1ab64ac

Please sign in to comment.