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

Fix legislation draft version TOC width #4255

Merged
merged 4 commits into from
Nov 17, 2020
Merged

Fix legislation draft version TOC width #4255

merged 4 commits into from
Nov 17, 2020

Conversation

javierm
Copy link
Member

@javierm javierm commented Nov 16, 2020

References

Objectives

  • Fix legislation draft version TOC width right after opening it / closing it
  • Make it possible to scroll through the TOC content when it's large enough to fill the whole window
  • Improve the draft version layout on small and medium screens

Visual Changes

Before these changes

Table of contents:

The table of contents is displayed so each line has only one word

On medium screens:

The width of the comment exceeds the width of the page

On small screens:

The icon to show/hide the table of contents is shown even if it does not work

After these changes

TODO

We were using different divs to show the same text in different
positions, but we can use the same one and rotate it when appropriate.
@javierm javierm self-assigned this Nov 16, 2020
@javierm javierm added this to Reviewing in Consul Democracy via automation Nov 16, 2020
@javierm javierm force-pushed the legislation_toc branch 3 times, most recently from 674ca3a to 7159864 Compare November 17, 2020 13:39
We were using JavaScript to show/hide the Table of Contents.

In my humble opinion, the <details> tag has a few shortcomings [1][2],
which means we should be careful about when to use it.

IMHO a Table of Contents is a good candidate for this tag because it's a
very common pattern to add a show/hide behavior for it, even if using it
means the "navigation" role (which we are *not* using anyway) wouldn't
be identified correctly.

I'm adding a <details> tag to the comments section as well for
consistency and in order to simplify the code. I'm not sure this is as
good an application of the <details> tag, though, but then again I'm not
sure about the interface we use to show/hide the comments (and this
feeling is increased by the fact that we use a different interface on
small screens). If we decide to change the interface in the future, we
might consider using the <details> tag for the Table of Contents but not
for the comments.

Since the <details> tag is not supported on Internet Explorer, I'm
only adding styles to this tag using the `:not([open])` option. On
Internet Explorer <details> will always be opened and so these styles
will be ignored.

[1] https://adrianroselli.com/2019/04/details-summary-are-not-insert-control-here.html
[2] https://daverupert.com/2019/12/why-details-is-not-an-accordion/
Now that comments and TOC can be closed at the same time, we use a flex
layout so the main content uses the available width.

We're also making the comments work better on medium-sized screens,
since previously they had a fixed width and now the width is adapted to
the size of the screen.

Since now the comment box element has a relative position instead of an
absolute one, we need to consider the draft panel height when
calculating the comment box position.
Originally we were using Foundation's sticky, which wasn't entirely
compatible with our way to open/close the Table of Contents because its
width would not automatically be updated when the TOC was opened/closed
but when users scrolled the page.

Using CSS, which is now supported in most browsers, simplifies the
matter. On browsers like Internet Explorer, where it's not supported,
the content will not stick but other than that it'll work fine.

We're also adding `scroll: auto` so when the TOC's height will be large
than the page, it'll be possible to scroll it, which users couldn't do
in the original version.
Consul Democracy automation moved this from Reviewing to Testing Nov 17, 2020
Copy link
Member

@Senen Senen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested successfully in a production environment!

@javierm javierm merged commit b5eed8c into master Nov 17, 2020
Consul Democracy automation moved this from Testing to Release 1.3.0 Nov 17, 2020
@javierm javierm deleted the legislation_toc branch November 17, 2020 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Table of contents not working properly
2 participants