2
0

🚸 (url) Improve URL input behavior on web

Closes #1074
This commit is contained in:
Baptiste Arnaud
2024-05-23 16:38:32 +02:00
parent 88d98f05a0
commit 3320e1b809

View File

@ -18,10 +18,6 @@ export const UrlInput = (props: Props) => {
let inputRef: HTMLInputElement | HTMLTextAreaElement | undefined
const handleInput = (inputValue: string) => {
if (!inputValue.startsWith('https://'))
return inputValue === 'https:/'
? undefined
: setInputValue(`https://${inputValue}`)
setInputValue(inputValue)
}
@ -29,6 +25,8 @@ export const UrlInput = (props: Props) => {
inputRef?.value !== '' && inputRef?.reportValidity()
const submit = () => {
if (inputRef && !inputRef?.value.startsWith('http'))
inputRef.value = `https://${inputRef.value}`
if (checkIfInputIsValid())
props.onSubmit({ value: inputRef?.value ?? inputValue() })
else inputRef?.focus()