Fixed dropdown appearing in input
This commit is contained in:
parent
de1e6bdc49
commit
4c153c05c5
1 changed files with 33 additions and 25 deletions
|
|
@ -99,12 +99,16 @@ export default function InputComponent({
|
||||||
type="text"
|
type="text"
|
||||||
onBlur={onInputLostFocus}
|
onBlur={onInputLostFocus}
|
||||||
value={
|
value={
|
||||||
selectedOption !== "" || !onChange ? selectedOption : value
|
(selectedOption !== "" || !onChange) && setSelectedOption
|
||||||
|
? selectedOption
|
||||||
|
: value
|
||||||
}
|
}
|
||||||
autoFocus={autoFocus}
|
autoFocus={autoFocus}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
(selectedOption !== "" || !onChange) && setShowOptions(true);
|
(selectedOption !== "" || !onChange) &&
|
||||||
|
setSelectedOption &&
|
||||||
|
setShowOptions(true);
|
||||||
}}
|
}}
|
||||||
required={required}
|
required={required}
|
||||||
className={classNames(
|
className={classNames(
|
||||||
|
|
@ -206,10 +210,12 @@ export default function InputComponent({
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
"pointer-events-auto absolute inset-y-0 h-full w-full cursor-pointer",
|
"pointer-events-auto absolute inset-y-0 h-full w-full cursor-pointer",
|
||||||
selectedOption !== "" || !onChange ? "" : "hidden"
|
(selectedOption !== "" || !onChange) && setSelectedOption
|
||||||
|
? ""
|
||||||
|
: "hidden"
|
||||||
)}
|
)}
|
||||||
onClick={
|
onClick={
|
||||||
selectedOption !== "" || !onChange
|
(selectedOption !== "" || !onChange) && setSelectedOption
|
||||||
? (e) => {
|
? (e) => {
|
||||||
setShowOptions((old) => !old);
|
setShowOptions((old) => !old);
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
@ -221,6 +227,7 @@ export default function InputComponent({
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{setSelectedOption && (
|
||||||
<span
|
<span
|
||||||
className={cn(
|
className={cn(
|
||||||
password && selectedOption === "" ? "right-8" : "right-0",
|
password && selectedOption === "" ? "right-8" : "right-0",
|
||||||
|
|
@ -245,6 +252,7 @@ export default function InputComponent({
|
||||||
/>
|
/>
|
||||||
</button>
|
</button>
|
||||||
</span>
|
</span>
|
||||||
|
)}
|
||||||
|
|
||||||
{password && selectedOption === "" && (
|
{password && selectedOption === "" && (
|
||||||
<button
|
<button
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue