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

Use Array.from(params).length instead of params.size in IssueStatusFilter #6

Open
SamirMishra27 opened this issue Nov 4, 2023 · 0 comments

Comments

@SamirMishra27
Copy link

Summary

If Issue Tracker is accessed from a safari browser (of version < 17) the Issue status filter is broken & hence would not filter the issues by their status, neither sort them by a particular column.

Why is this happening?
Inside the callback method of Issue Status Filter's onValueChange, the size property is used to check if there are any Url search params or not.

const query = params.size ? '?' + params.toString() : '';
router.push('/issues/list' + query);

The problem is that UrlSearchParams.size property is not widely supported on Safari browsers. The size property was only recently supported on Safari version 17 of both iOS & Mac which was released on 26-09-2023, according to MDN. This is also around the time when this course was being recorded.

As per the usage table of browser versions globally by caniuse.com only 16% of users have Safari version 17 & above, rest of the users are using version 16 or below.

In short, there is a lack of browser support for this property on current & older safari browsers, causing potential issues for those who try to access this Issue Tracker on their Safari.

Proposed solution

The proposed solution is to use this code:

        const query = Array.from(params.size).length ? '?' + params.toString() : '';
        router.push('/issues/list' + query);

Or we could just call the toString() method first & only router push if string isn't a falsey value.

And then give a advisory to students on this lecture's description https://members.codewithmosh.com/courses/nextjs-projects-issue-tracker/lectures/49642661 to modify their code if the Issue Status Filter is not working on their browser.

Thank you if you consider this proposal.
@mosh-hamedani

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant