Skip to content

Commit

Permalink
Scroll immediately after clicking an image
Browse files Browse the repository at this point in the history
  • Loading branch information
unstubbable committed Mar 16, 2024
1 parent 6fb94af commit c7c9f6e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/app/image-selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ export function ImageSelector({
const [, setMessages] = useUIState<typeof AI>();
const {submitUserMessage} = useActions<typeof AI>();

const formAction = async () => {
const handleClick = async () => {
document.body.scrollIntoView({block: `end`, behavior: `smooth`});

try {
const message = await submitUserMessage(
`Tell me more about image ${url}, keep it short.`,
Expand All @@ -36,5 +38,9 @@ export function ImageSelector({
document.body.scrollIntoView({block: `end`, behavior: `smooth`});
};

return <button formAction={formAction}>{children}</button>;
return (
<button type="button" onClick={handleClick}>
{children}
</button>
);
}

0 comments on commit c7c9f6e

Please sign in to comment.