Skip to content

Selecting an item after querying resets the query result #131

@iwatakeshi

Description

@iwatakeshi

Question

Hi, I'm currently on Chapter 8 reading so I apologize in advance if this has already been addressed in later chapters, but I thought to share a fix for a potential issue. I noticed that when one queries in the search input box and selects a result, the list resets back to the state where no queries were performed. I think that there needs to be an update to the ListLinkItem in dashboard.expenses.tsx like so (also for income):

<ListLinkItem
  key={expense.id}
- to={`/dashboard/expenses/${expense.id}`}
+ to={
+ searchQuery ? 
+   `/dashboard/expenses/${expense.id}?q=${searchQuery}`
+   : `/dashboard/expenses/${expense.id}`
+ }
   isActive={expense.id === id}
   deleteProps={{
     ariaLabel: `Delete ${expense.title} expense`,
     action: `/dashboard/expenses/${expense.id}`,
  }}>

I'm writing this as a question since I'm new to Remix and I don't know its best practices yet. 😅

By the way, it's a great read so far. Thank you!

Context

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingwith solutionTag for bug tickets that document the solution

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions