Skip to content

Commit 64b2730

Browse files
author
Amandee Ellawala
committed
Fix #223 prevent resetting star range and sort order when selecting a language
1 parent cc1a301 commit 64b2730

File tree

1 file changed

+3
-2
lines changed
  • src/app/(public)/repos/[language]/_components

1 file changed

+3
-2
lines changed

src/app/(public)/repos/[language]/_components/sorter.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ enum SortTypes {
2323
export function Sorter() {
2424
const searchParams = useSearchParams();
2525
const pathname = usePathname();
26+
const urlSearchParam = new URLSearchParams(searchParams);
2627

2728
const navigationItems = [
2829
{
@@ -129,7 +130,7 @@ export function Sorter() {
129130
<ul tabIndex={0} className="menu menu-vertical">
130131
{mainLanguages.sort(sortByName).map(language => (
131132
<li key={language} onClick={handleClick}>
132-
<Link href={`/repos/${language.toLowerCase()}`}>
133+
<Link href={`/repos/${language.toLowerCase()}?${urlSearchParam.toString()}`}>
133134
{language}
134135
</Link>
135136
</li>
@@ -148,7 +149,7 @@ export function Sorter() {
148149
<div className="z-50 h-64 p-2 overflow-y-scroll shadow dropdown-content hidden group-hover:block -ml-16 bg-base-100 rounded-box w-60">
149150
<ul tabIndex={0} className="menu menu-vertical">
150151
{navigationItems.map((item, index) => {
151-
const sp = item.onSelect(new URLSearchParams(searchParams));
152+
const sp = item.onSelect(urlSearchParam);
152153
if (item.name === SortTypes.BestMatch) {
153154
sp.delete('o');
154155
sp.delete('s');

0 commit comments

Comments
 (0)