diff --git a/src/components/forms/AddItemForm.tsx b/src/components/forms/AddItemForm.tsx index 96fd378..bd06e48 100644 --- a/src/components/forms/AddItemForm.tsx +++ b/src/components/forms/AddItemForm.tsx @@ -1,3 +1,4 @@ +import { useRef } from "react"; import { ChangeEvent, FormEvent, useState } from "react"; import { addItem, ListItem } from "../../api"; import { validateItemName } from "../../utils"; @@ -96,13 +97,6 @@ export function AddItemForm({ listPath, data: unfilteredListItems }: Props) { } }; - const navigateToListPage = () => { - if (listPath) { - const listName = listPath.split("/").pop(); - navigate(`/list/${listName}`); - } - }; - return (
handleSubmit(e, listPath)}> @@ -188,7 +182,6 @@ export function AddItemForm({ listPath, data: unfilteredListItems }: Props) { -
); } diff --git a/src/views/authenticated/List.tsx b/src/views/authenticated/List.tsx index ad5ede1..3183e07 100644 --- a/src/views/authenticated/List.tsx +++ b/src/views/authenticated/List.tsx @@ -77,6 +77,15 @@ export function List({ data: unfilteredListItems, listPath }: Props) { } }; + const viewListRef = useRef(null); + + // Function to handle scrolling to the Add-ShareList section + const scrollToViewList = () => { + if (viewListRef.current) { + viewListRef.current.scrollIntoView({ behavior: "smooth" }); + } + }; + // Main content when list is not empty return ( @@ -102,7 +111,7 @@ export function List({ data: unfilteredListItems, listPath }: Props) { -
+
{filteredListItems.map((item) => ( ))} @@ -120,6 +129,8 @@ export function List({ data: unfilteredListItems, listPath }: Props) {
+ + ); }