-
Notifications
You must be signed in to change notification settings - Fork 641
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
show more link jumps problem #8501
Conversation
@@ -517,7 +517,7 @@ | |||
@Html.Raw(Model.ReadMeHtml) | |||
</div> | |||
|
|||
<a href="#" role="button" data-toggle="collapse" class="icon-link" data-target="#readme-more" | |||
<a href="#show-readme-container" role="button" data-toggle="collapse" class="icon-link" data-target="#readme-more" |
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.
Hmm.. if this is the fix it seems that the click event is bubbling out and the default (navigation) behavior is remaining.
https://stackoverflow.com/a/866587
This is just making the viewport jump to this link, right?
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.
I am confused by the GIF -- does the value in the address bar change?
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.
when we click show-more, viewport jump to this link(https://localhost/packages/embeddedReadmeTestApp/#show-readme-container
insteadof https://localhost/packages/embeddedReadmeTestApp/#
).
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.
This should not be necessary. This is a button (as evidenced by the role
attribute not a traditional link. A navigation event should not even occur. See that Stack Overflow above. Is the event bubbling out of this click handler?
NuGetGallery/src/NuGetGallery/Scripts/gallery/page-display-package.js
Lines 67 to 70 in be38792
$("#show-readme-more").click(function (e) { | |
showLess.collapse("toggle"); | |
e.preventDefault(); | |
}); |
I'm wondering if perhaps this behavior regressed when we updated jQuery...
Maybe we just need return false
in that method?
Ideally nothing happens in the address bar when you click this button. It's not really a link, per se.
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.
Looks like return false
works, nothing happens in the address bar when we click this button.
@@ -74,6 +74,7 @@ $(function () { | |||
showLess.on('show.bs.collapse', function (e) { | |||
e.stopPropagation(); | |||
}); | |||
return false; |
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.
this is not where I would expect it. I would expect the return false
in the event (click) handler. Maybe this very long SO answer will help clarify the situation for you?
https://stackoverflow.com/a/30473685
Let's sync offline if things are still confusing :)
This reverts commit c7a2355.
Summary of the changes (in less than 80 characters):
before changes:
Clicking the Show More link clears the URL fragment and goes to the top of the page.
after changes:
The README should expand but the viewport should stay where it is.
Addresses #8461