-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Prevent empty query parameter being set on dashboard #11561
Merged
zeripath
merged 4 commits into
go-gitea:master
from
zeripath:only-show-query-on-dashboard-if-query-empty
May 24, 2020
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0f18906
prevent empty query parameter being set on dashboard
zeripath 12358f0
Merge branch 'master' into only-show-query-on-dashboard-if-query-empty
jolheiser 0db49e6
Merge branch 'master' into only-show-query-on-dashboard-if-query-empty
zeripath 2ae4b41
Merge branch 'master' into only-show-query-on-dashboard-if-query-empty
zeripath File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this branch even necessary? This would kill any
#hash
present on the URL (thought the branch above would also)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a helper function you can put in
utils.js
that preserves pathname, search and hash:You can then call it like this to set/unset only the
search
part:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hash is will be out of date and irrelevant if you are pressing these buttons - if anything we should be setting the hash to reference the repo-list table.
Imagine we finally get round to sticking ids on the newsfeed items and you have been sent the newsfeed via an anchor then have scrolled back up to the repo-list - keeping the anchor would mean that on going back you will scroll back to the anchor even though the actual proper context for those query elements is the repo-list.
As the repo-list is the top of the page it's not necessarily needed to set the anchor hash - but - keeping it could be confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove the hash too with it. This should be equal to your version:
Your first case would set a wrong path if gitea is running on a subdirectory as it would set path to parent root directory. I think my function is safer because it only sets the parts that you want to change, not all at once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, it seems a
replaceState
with?something
as URL does not kill the path, at least in Firefox. But I would probably not want rely that this behaviour is the same in all browsers.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I think your way is actually fine. I did not realize browsers were smart enough to do the right thing for
?search
and#hash
pseudo urls, but it appears to be working fine because the url standard requires to apply the base url so fragments like this will work.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hehe! one of the things that I've recently realised is that it is helpful to run your testing instance through a proxy mounted on a suburl (https://localhost/gitea) as it catches a lot of simple problems.