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 alignment styling issues in listings #11933

Closed
wants to merge 3 commits into from

Conversation

laymonage
Copy link
Member

@laymonage laymonage commented May 7, 2024

See #11870 (comment) and commit messages for more details. Hide whitespace when reviewing.

Before

image

After

image

While we intend these styles to vertically align the title cells, this
wasn't a good idea for a few reasons:

- The styles get applied to both td and th elements
- Even if we limit this to td.title, setting display: flex directly on
  the td element is bad, as it would cause the table layout to break in
  some cases (e.g. if two td.title elements are adjacent)

Remove these styles for now. This doesn't cause too much issue, since
most things that need to be vertically centered are usually in a
.title-wrapper element, which we have fixed in
b8dd7f4. The only issue is that now the
"..." actions button may not be vertically centered when the title is
long. That will need to be fixed by introducing another wrapper that
wraps the .title-wrapper and the .actions elements together.
Copy link

squash-labs bot commented May 7, 2024

Manage this branch in Squash

Test this branch here: https://laymonagefix-listing-styles-t1c47.squash.io

@laymonage laymonage force-pushed the fix-listing-styles branch 3 times, most recently from acb0d13 to 2654cdf Compare May 7, 2024 12:41
@@ -18,43 +18,45 @@
{% for page in locked_pages %}
<tr>
<td class="title" valign="top">
<div class="title-wrapper">
<a href="{% url 'wagtailadmin_pages:edit' page.id %}" title="{% trans 'Edit this page' %}">{{ page.get_admin_display_title }}</a>
<div class="w-flex w-items-center w-justify-between w-gap-2">
Copy link
Contributor

Choose a reason for hiding this comment

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

question: is there scope to bring these into one, more semantic class?

Copy link
Member Author

Choose a reason for hiding this comment

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

I did consider it, but the current state of the HTML+CSS for the listings is very poor, and I wasn't sure if it's worth adding yet another class to listing.scss at the moment. The code badly needs a refactor to also align with our latest conventions (e.g. using w- prefix, not using float, etc.), so I chose not to add a new class for now. Wouldn't mind adding it if @thibaudcolas thinks it's a good idea though.

Comment on lines -226 to -229
display: flex;
align-items: center;
justify-content: space-between;
gap: theme('spacing.2');
Copy link
Member Author

Choose a reason for hiding this comment

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

This was added in 08ee15a. I assumed that since all listing 'actions' are now inside the dropdown, we'd want to apply these vertically-centering styles to the td.title everywhere. This was wrong because:

  • The styles get applied to both td.title and th.title elements
  • Even if we limit this to td.title, setting display: flex directly on the td element is bad, as it would cause the table layout to break in some cases (e.g. if two td.title elements are adjacent). This issue technically also existed in the old --inline-actions styles before 08ee15a, but it was pretty isolated as only HistoryView used it.

Remember, the main goal is to vertically center:

  • Any icons and locale tags in the title

    Screenshot

    image

  • The above, combined with the ... dropdown actions.

    • However, the dropdown actions button cannot be put in the same element that wraps the title and icons (.title-wrapper), because we also want to use justify-content: space-between to provide the space between the title and the button (instead of using float: inline-end).
    • As a result, the second commit in this PR adds a new wrapper to make this possible.

@@ -1,17 +1,14 @@
{% extends "wagtailadmin/tables/title_cell.html" %}
Copy link
Member Author

@laymonage laymonage May 7, 2024

Choose a reason for hiding this comment

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

This technically isn't a title cell but the markup used to make use of the title CSS classes for styling purposes, this went as far back as v2.16 (possibly earlier) https://static-wagtail-v2-16.netlify.app/admin/workflows/list/:
image

Instead of making this extend the title cell, turn this into an independent column template, and use w-label-1 on the link to achieve similar styling.

Before

image

After

image

@laymonage laymonage self-assigned this May 7, 2024
@laymonage laymonage added type:Bug component:Universal listings Including page listings, model listings and filtering. labels May 7, 2024
@laymonage laymonage added this to the 6.1.1 milestone May 7, 2024
@laymonage
Copy link
Member Author

I'm wary that this PR changes too much and might introduce more issues than it solves. I've opted to revert the changes that caused all the issues instead, in #11936.

@laymonage laymonage closed this May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:Universal listings Including page listings, model listings and filtering. type:Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants