Skip to content

Commit e1c6ff0

Browse files
committed
Button fixed for safari
1 parent 15f85bc commit e1c6ff0

1 file changed

Lines changed: 1 addition & 44 deletions

File tree

frontend/src/utility/ToggleSelection.tsx

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
import { useState } from "react";
2-
import edit from "../assets/edit.png";
31
import Tooltip from "./Tooltip";
42

5-
const EXTRA_DEFAULT = "Custom";
6-
73
interface ToggleSelectionProps<T> {
84
label: string;
95
options: Array<T>;
@@ -25,33 +21,12 @@ const ToggleSelection = <T,>({
2521
setState,
2622
currentState,
2723
capitalize = false,
28-
extraInput = false,
2924
flexGrow = false,
3025
disabled = [],
3126
zIndex = '', // FIX: Horrible implementation but don't want to waste time on a z-index
3227
color = 'None'
3328
}: ToggleSelectionProps<T>) => {
3429

35-
const [extra, setExtra] = useState(EXTRA_DEFAULT);
36-
37-
const extraFocus = (value: any, initial: boolean = false) => {
38-
setExtra((initial && value == EXTRA_DEFAULT) ? "" : value);
39-
if (value == Number(value)) setState(value as unknown as T);
40-
}
41-
42-
const extraUnfocus = (value: any) => {
43-
if (value === "") {
44-
setExtra(EXTRA_DEFAULT);
45-
setState(options[0]);
46-
return;
47-
}
48-
49-
setExtra(value);
50-
51-
const isNumber = !isNaN(value);
52-
setState(isNumber ? value : options[0]);
53-
};
54-
5530
// Tailwind no dynamic class generation moment
5631
let border = 'border-hpi-orange';
5732
let borderHover = 'hover:border-b-hpi-orange/30'
@@ -70,7 +45,7 @@ const ToggleSelection = <T,>({
7045
{options.map((option, index) => (
7146
<button
7247
key={String(option)}
73-
onFocus={() => setState(option)}
48+
onMouseDown={() => setState(option)}
7449
disabled={disabled.includes(option)}
7550
className={`border-b-4 duration-150 ${zIndex}
7651
${flexGrow ? 'flex-1' : 'px-4'}
@@ -84,24 +59,6 @@ ${disabled.includes(option) ? "cursor-not-allowed text-gray-300 hover:border-b-t
8459
</Tooltip>
8560
</button>
8661
))}
87-
{ extraInput &&
88-
<div className={`flex group border-b-4 justify-evenly items-start flex-1 duration-150 ${
89-
currentState == extra ?
90-
`${color == 'New' ? 'border-b-hpi-new ' : 'border-b-hpi-current'}` :
91-
'border-b-transparent'
92-
}`}>
93-
<input type="text" className={`
94-
${currentState == extra ? `${border} font-bold` : `border-b-transparent ${borderHover}`}
95-
cursor-pointer text-center duration-150
96-
${color == 'New' ? 'focus:outline-hpi-new/30' : 'focus:outline-hpi-current/30'}
97-
w-14`}
98-
onFocus={(e) => extraFocus(e.target.value, true)}
99-
onChange={(e) => extraFocus(e.target.value)}
100-
onBlur={(e) => extraUnfocus(e.target.value)}
101-
value={extra} />
102-
<img src={edit} className="h-5" />
103-
</div>
104-
}
10562
</div>
10663
);
10764
};

0 commit comments

Comments
 (0)