okkur / syna

Highly customizable open source theme for Hugo based static websites
https://syna.okkur.org/demo/
Apache License 2.0
250 stars 134 forks source link

Sidebar with sticky = true #700

Closed Cloud-Forge closed 4 years ago

Cloud-Forge commented 4 years ago

Is this a BUG REPORT or FEATURE REQUEST?: bug

What happened: The sidebar sticky = true doesn't stick !

content.html (content fragment)

if you choose sticky = true for the sidebar in a content fragment. The sidebar doesn't stick.

What you expected to happen: the side should stick when one scroll down. but it doesn't !

How to reproduce it (as minimally and precisely as possible): To reproduce get a content fragment with a sidebar (either left or right) set the sticky Boolean to true, check in the source code that the class

sticky-top pt-3

is set for the child element of content-sidebar Then scroll down, you'll see that the element is not sticky.

Anything else we need to know?: I tried with

I think that the problem comes from the fact that the parent element of #sticky-top div : aka :

.content-sidebar {
  word-break: break-word;
  overflow-y: auto;
}

has got the style : overflow-y: auto;

I made it work by adding one div around the first sticky-top :

        {{- if .sticky }}
          <div class="sticky-top pt-3"> <div class="pt-3">
        {{- end -}}

[...]

    {{- if .sticky }}
          </div></div> {{/* .sticky-top */}}
          <div></div>
        {{- end -}}

and I add in _syna.css:

.sticky-top{
    top: 50px;
}

and remove overflow-y from :

.content-sidebar {
  word-break: break-word;
/*   overflow-y: auto; */
}

Environment:

stp-ip commented 4 years ago

Thanks for the report and the details. Happy for @mpourismaiel to jump in and happy to receive a PR once we get an ack.

mpourismaiel commented 4 years ago

That line was added in 01ebc833018f05b356e37547a4990f7ec8532670 but I'm not sure why I added it to that commit (I really have to separate concerns when committing). Removing the overflow-y: auto; line would prevent sidebar from scrolling on overflow which I believe would be a bigger problem. I haven't found a solution for it though so I think keeping this bug is preferable to fixing it and adding a bigger bug. (visual vs accessibility.) What do you think @stp-ip ?

stp-ip commented 4 years ago

Moving this to the next milestone. Will try to figure out a feasible solution without breaking overflow scrolling.

stp-ip commented 4 years ago

This seems related to #601 as well.