Skip to content

Commit

Permalink
Revert "Add the correct input type attribute to edit inputs"
Browse files Browse the repository at this point in the history
This reverts commit 6fdda51.
  • Loading branch information
Dlurak committed Oct 16, 2024
1 parent ae013fc commit 5714512
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useEditDialogContext } from '../../helpers/EditDialogContext';
import { useEditContext } from '../EditContext';
import { OpeningHoursEditor } from './OpeningHoursEditor/OpeningHoursEditor';
import styled from '@emotion/styled';
import { CharacterCount, getInputTypeForKey } from './helpers';
import { CharacterCount } from './helpers';

export const majorKeys = [
'name',
Expand All @@ -21,7 +21,7 @@ export const majorKeys = [

const MAX_INPUT_LENGTH = 255;

const getData = (numberOfWikimediaItems: number) => {
const getData = (numberOfWikimediaItems) => {
const wikimediaCommonTags = Array(numberOfWikimediaItems)
.fill('')
.reduce((acc, _, index) => {
Expand All @@ -47,30 +47,19 @@ const InputContainer = styled.div`
position: relative;
`;

type TextFieldProps = {
k: string;
label: string;
onChange: React.ChangeEventHandler<HTMLInputElement | HTMLTextAreaElement>;
value?: string;
autoFocus?: boolean;
};

const TextFieldWithCharacterCount = ({
k,
label,
autoFocus,
onChange,
value,
}: TextFieldProps) => {
}) => {
const [isFocused, setIsFocused] = useState(false);
const inputType = getInputTypeForKey(k);

return (
<InputContainer>
<TextField
label={label}
type={inputType}
multiline={inputType === 'text'}
multiline
value={value}
InputLabelProps={{ shrink: true }}
variant="outlined"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useEditDialogContext } from '../../../helpers/EditDialogContext';
import { useEditContext } from '../../EditContext';
import { IconButton, Stack, TextField } from '@mui/material';
import DeleteIcon from '@mui/icons-material/Delete';
import { getInputTypeForKey } from '../helpers';

const useHidableDeleteButton = () => {
const buttonRef = useRef<HTMLButtonElement>(null);
Expand Down Expand Up @@ -35,10 +34,7 @@ const DeleteButton = ({ deleteButton, index }: DeleteButtonProps) => {
setTagsEntries((state) => state.toSpliced(index, 1));
};

if (!deleteButton.shown) {
return null;
}
return (
return deleteButton.shown ? (
<IconButton
size="small"
onClick={onClick}
Expand All @@ -47,7 +43,7 @@ const DeleteButton = ({ deleteButton, index }: DeleteButtonProps) => {
>
<DeleteIcon fontSize="small" />
</IconButton>
);
) : null;
};

type Props = { index: number };
Expand All @@ -69,7 +65,6 @@ export const ValueInput = ({ index }: Props) => {
return (
<Stack direction="row" spacing={1} alignItems="center">
<TextField
type={getInputTypeForKey(currentKey)}
value={currentValue}
onChange={handleChange}
fullWidth
Expand Down
22 changes: 0 additions & 22 deletions src/components/FeaturePanel/EditDialog/EditContent/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,3 @@ export const CharacterCount = ({
</Stack>
</CharacterCountContainer>
) : null;

export const getInputTypeForKey = (key: string) => {
switch (key) {
case 'fax':
case 'phone':
case 'mobile':
case 'contact:phone':
case 'contact:whatsapp':
case 'contact:mobile':
case 'contact:tty':
case 'contact:sms':
case 'contact:fax':
return 'tel';
case 'contact:website':
case 'website':
return 'url';
case 'contact:email':
case 'email':
return 'email';
}
return 'text';
};

0 comments on commit 5714512

Please sign in to comment.