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

x/tools/cmd/godoc: results page jumps during rendering #21685

Closed
bcmills opened this issue Aug 29, 2017 · 8 comments

Comments

Projects
None yet
4 participants
@bcmills
Copy link
Member

commented Aug 29, 2017

Example page: https://tip.golang.org/search?q=testing

The results initially render with the (IMO) most useful package links,¹ then replace them a short time later with a long list of cross-references.² If you try to click on one of the package links, you're fairly likely to end up on an arbitrarily different page than you intended.

Ideally, the whole page should load instantly. However, if that is not possible, we should structure the page so that it does not jump around as it loads.

(CC: @alandonovan @stamblerre)

¹rsec5dcglnt

²01paakzo3ju

@agnivade

This comment has been minimized.

Copy link
Member

commented Aug 7, 2018

The cross-references are generated post document load event, through some javascript. Currently, it has a very rudimentary heuristic which just splits the elements into 2 columns if it exceeds a threshold. Also, it uses <table> tags to display the code which is not very elegant.

Ideally, we should make all these decisions server side and send a properly structured data to the client.

So then,

  • no more page jumps (because no js gets executed post doc load)
  • does not fill the entire page (because fine tuned display logic is sent pre-computed)
  • should take care of #21686 too since everything will get displayed in one shot.

I will take a look at it for 1.12.

@agnivade agnivade self-assigned this Aug 7, 2018

@jimmyfrasche

This comment has been minimized.

Copy link
Member

commented Aug 7, 2018

For the layout itself, there's https://caniuse.com/#feat=multicolumn Despite having good support on paper, it's still kinda buggy. Even when everything's working right it never quite seems to work as well as advertised. It's always hard to say if it will work in a given situation, but, when it does, it works well and is simpler than the alternatives. So, even if it ultimately doesn't work, it's usually worth trying it first.

@agnivade

This comment has been minimized.

Copy link
Member

commented Aug 7, 2018

Thanks. I have used it before. Will give it a shot.

@bcmills bcmills added the NeedsFix label Aug 7, 2018

@agnivade

This comment has been minimized.

Copy link
Member

commented Aug 8, 2018

Nearly got it working. Only slight issue is that there is no notion of minimum column-height. So all elements will fill to all the columns. Therefore, it looks odd if the no. of elements is low.

cc

In this case, it looks good if they are split into 2 columns. To fix this, I can add some heuristics and send an appropriate css class attached to the div from server side. But then, it would require 4 classes in the css file, each for a separate column-count value. I would really like a native css solution to this.

@jimmyfrasche - Any way to tackle this ?

paging other css wizards too @andybons

@jimmyfrasche

This comment has been minimized.

Copy link
Member

commented Aug 8, 2018

You could inject custom properties into the dom with an appropriately placed style="--max-cols: 2;" based on the server-side heuristics

@agnivade

This comment has been minimized.

Copy link
Member

commented Aug 8, 2018

Hmm .. not the most elegant solution. But works. No way to make minimum column height I guess ?

@jimmyfrasche

This comment has been minimized.

Copy link
Member

commented Aug 8, 2018

Not that I am aware of.

@gopherbot

This comment has been minimized.

Copy link

commented Aug 11, 2018

Change https://golang.org/cl/129135 mentions this issue: godoc: generate TOC from server-side for search page

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.