Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I don't know what's wrong #2

Open
userAugustos opened this issue Dec 5, 2023 · 0 comments
Open

I don't know what's wrong #2

userAugustos opened this issue Dec 5, 2023 · 0 comments
Labels
help wanted Extra attention is needed

Comments

@userAugustos
Copy link

I tried to use it, with React router v6

so, i have router config with createBrowserRouter:

  const router = createBrowserRouter([
    {
      path: '/',
      element: <Layout />,
      children: [
        {
          path: '/',
          element: <Home />,
        },
        {
          path: '/dashboard',
          element: <Dashboard />,
        },
      ],
    },
  ]);

then in the Home component i'm rendering a chat:

<div>
   <div
          id="chatContainer"
          className="h-full flex flex-col gap-3 overflow-y-scroll scroll-smooth"
          ref={ref}
        >
          {renderHelper}
   </div>
   <ElementScrollRestoration elementQuery="#chatContainer" />
</div>      

The renderHelper only makes some validating, and insert prompts and answers, it scrolls, cool, but when i nav to Dashboard, and comeback to Home, the scroll position is not saved, it at top

I will provide a Codesandbox later, but i don't know if i can recreate the exact thing, because it's a bigger project, with many things rappening on the chat.

But i think the scroll part is this, the #chatContainer, render on page load, and stays there forever, even if has no messages, so the reference to the ElementScrollRestoration exists

@kentcdodds kentcdodds added the help wanted Extra attention is needed label Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants