From 3320e1b809bbc6384e73b41842b11b989f81779d Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Thu, 23 May 2024 16:38:32 +0200 Subject: [PATCH] :children_crossing: (url) Improve URL input behavior on web Closes #1074 --- .../src/features/blocks/inputs/url/components/UrlInput.tsx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/embeds/js/src/features/blocks/inputs/url/components/UrlInput.tsx b/packages/embeds/js/src/features/blocks/inputs/url/components/UrlInput.tsx index e60e39088..b9d72002c 100644 --- a/packages/embeds/js/src/features/blocks/inputs/url/components/UrlInput.tsx +++ b/packages/embeds/js/src/features/blocks/inputs/url/components/UrlInput.tsx @@ -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()