Skip to content

Commit

Permalink
handle onblur for emebed domains (#2199)
Browse files Browse the repository at this point in the history
bump browser extension commit
handle onblur for emebed domains
  • Loading branch information
timothycarambat authored Aug 29, 2024
1 parent 334fd9c commit bc0cc20
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion browser-extension
Submodule browser-extension updated 1 files
+6 −0 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,25 @@ export const PermittedDomains = ({ defaultValue = [] }) => {
setDomains(validDomains);
};

const handleBlur = (event) => {
const currentInput = event.target.value;
if (!currentInput) return;

const validDomains = [...domains, currentInput].map((input) => {
let url = input;
if (!url.includes("http://") && !url.includes("https://"))
url = `https://${url}`;
try {
new URL(url);
return url;
} catch {
return null;
}
});
event.target.value = "";
setDomains(validDomains);
};

return (
<div>
<div className="flex flex-col mb-2">
Expand All @@ -270,6 +289,7 @@ export const PermittedDomains = ({ defaultValue = [] }) => {
<TagsInput
value={domains}
onChange={handleChange}
onBlur={handleBlur}
placeholder="https://mysite.com, https://anythingllm.com"
classNames={{
tag: "bg-blue-300/10 text-zinc-800 m-1",
Expand Down

0 comments on commit bc0cc20

Please sign in to comment.