Page MenuHomePhabricator

Accordion: Use flexbox for layout of action button within summary
Closed, ResolvedPublic2 Estimated Story PointsBUG REPORT

Assigned To
Authored By
egardner
Apr 29 2025, 5:01 PM
Referenced Files
F66015157: image.png
Sep 11 2025, 9:50 PM
F66015154: image.png
Sep 11 2025, 9:50 PM
F66015022: Accordion_flexbox.gif
Sep 11 2025, 7:15 PM
F66008293: Screenshot 2025-09-11 at 08.56.36.png
Sep 11 2025, 12:57 PM
F66008289: Screenshot 2025-09-11 at 08.53.44.png
Sep 11 2025, 12:57 PM
F66008287: Screenshot 2025-09-11 at 08.53.31.png
Sep 11 2025, 12:57 PM
F65912819: Screenshot 2025-08-25 at 21.08.12.png
Aug 26 2025, 1:19 AM
F65912817: Screenshot 2025-08-25 at 21.08.23.png
Aug 26 2025, 1:19 AM

Description

Currently the Accordion's "action button" element is aligned within the header using absolute positioning. This takes the button out of the document flow, and creates the potential for collisions with text to occur if there is a long title or description:

Screenshot 2025-04-28 at 9.48.06 AM.png (1,184×338 px, 72 KB)

We should use a flexbox-based positioning strategy to arrange these elements, making the button square, and flush with the edges of the accordion header. The icon should stay centered with the first line of the header text, like the chevron icon on the left already does, and the button should be the same height as the first line of text (note that this height might change depending on the font mode).

Screenshot 2025-08-25 at 21.09.50.png (1,268×126 px, 19 KB)

Screenshot 2025-08-25 at 21.10.02.png (1,278×208 px, 31 KB)

Screenshot 2025-08-25 at 21.10.29.png (1,274×130 px, 20 KB)

Screenshot 2025-08-25 at 21.10.21.png (1,284×226 px, 33 KB)

Screenshot 2025-08-25 at 21.09.04.png (1,262×194 px, 30 KB)

Screenshot 2025-08-25 at 21.09.12.png (1,272×288 px, 43 KB)

Screenshot 2025-08-25 at 21.08.23.png (1,276×224 px, 32 KB)

Screenshot 2025-08-25 at 21.08.12.png (1,274×300 px, 44 KB)


Follow-up task: T405956: Accordion: investigate alternative approach to negative margins

Event Timeline

egardner set the point value for this task to 2.

Change #1139140 had a related patch set uploaded (by Eric Gardner; author: Eric Gardner):

[design/codex@main] Accordion: Use flexbox instead of positioning for action button

https://gerrit.wikimedia.org/r/1139140

  • The height of the button would ideally be 32px, the typical size of our buttons. Whether or not a token is used for the height or it's set some other way, doesn't matter to me as much.
  • Ideally, the button should remain its original size and position, i.e. square, when the title and/or description become long.
  • If we could make the button flush to the edges (mainly top and right for LTR) that would be ideal. If not, and if that requires an unreasonable amount of code or effort, then I think having the same padding as the Accordion header is okay.
  • Similarly to our buttons currently, the size of the button should not change with the changing in font modes.

Would like to see a demo to design review this after changes are made.

Assuming this task is about the Codex code project, hence adding that project tag so other people who don't know or don't care about team tags can also find this task when searching via projects or looking at workboards. Please set appropriate project tags when possible. Thanks.

Catrope added a project: Reader Growth Team.
Catrope moved this task from In Progress to Ready for Design/Dev on the Codex board.
Catrope moved this task from Incoming/Inbox to Needs Refinement on the Reader Growth Team board.
Catrope subscribed.

I think we need some updated design mockups to cover the various scenarios – multi-line title and multi-line description with button, etc.

Okay, here are some revised designs with the proposed design solution. The button should be square, and the ultimate goal is that the button is ideally flush with the edges of the accordion header, and the icon should stay centered with the first line of the header text, just as the chevron icon at the start does. So the height (and therefore width) of the button should remain the size of the header height with one line of text whether or not there is one line of text. Now, with font modes, the height of the accordion/header with one line of text changes, so that's something to keep in mind.

Screenshot 2025-08-25 at 21.09.50.png (1,268×126 px, 19 KB)

Screenshot 2025-08-25 at 21.10.02.png (1,278×208 px, 31 KB)

Screenshot 2025-08-25 at 21.10.29.png (1,274×130 px, 20 KB)

Screenshot 2025-08-25 at 21.10.21.png (1,284×226 px, 33 KB)

Screenshot 2025-08-25 at 21.09.04.png (1,262×194 px, 30 KB)

Screenshot 2025-08-25 at 21.09.12.png (1,272×288 px, 43 KB)

Screenshot 2025-08-25 at 21.08.23.png (1,276×224 px, 32 KB)

Screenshot 2025-08-25 at 21.08.12.png (1,274×300 px, 44 KB)

egardner lowered the priority of this task from High to Low.Sep 2 2025, 10:15 PM

Hey @DTorsani-WMF, I updated the existing patch to apply flexbox to the Accordion (demo). The chevron indicator icon, header, and action button are aligned to the beginning of a flex container (flex-start). The action button is square and maintains 32x32 dimensions in different font modes. To align the action button flush to the top-right corner, the button is offset relative to itself (https://developer.mozilla.org/en-US/docs/Web/CSS/position).

// Action button is flush to the edge of the parent container by offsetting it relative to itself.
position: relative;
bottom: @spacing-75; // same as parent container's padding 12px
left: @spacing-75;

Notes:

  • The alignment is slightly off in larger font modes (large and extra-large) when the buttons are flush to the edge. It could just be that it's more apparent in the larger font modes 🤔 [I'll send a video via Slack because the file is too large]
  • Chevron icon, header, and action button are aligned to the beginning of the container in patchsets 3 and 4. To download a specific patchset of a change, use git review -d 1139140,3 to download patchset 3 of change 1139140.
    • Patchset 3: Button is not flush to the edge ("basic" approach)
    • Patchset 4: Button is flush to the edge

What are your thoughts on this approach?

Thanks for providing this update @lwatson. A couple thoughts:

  • For patchset 3, when the action button is applied, it changes the height of the overall accordion, which is not intended. The action button is centered, which is right, but it means the text and chevron become misaligned with the overall accordion. The action button should not change the height of the accordion header.

Screenshot 2025-09-11 at 08.53.31.png (1,260×108 px, 18 KB)

Screenshot 2025-09-11 at 08.53.44.png (1,258×128 px, 19 KB)

  • For patchset 4, if the button is flush to the edges, it should be the height of the accordion with one line of text, that way it is centered with the first line of text.

Screenshot 2025-09-11 at 08.56.36.png (1,260×132 px, 13 KB)

That being said, I prefer patchset 3, the more basic approach. Can you move forward with this and fix the height issue?

Thanks @DTorsani-WMF, I'll share an update later today

@DTorsani-WMF I updated the patch.

Updates:

  • Fixed the alignment issue by positioning the action button to the top of the flex container (align-self: flex-start).
  • Applied negative margins to the top and bottom of the action button to offset the 4px extra height (2px padding + 2px border). Now, the Accordion's 52px height (for single-line header titles) is consistent whether the action button is present or not.

Thanks @lwatson! However, I'm not seeing that anything has changed in the demo. I see your code reflects your comment here, but the height issue and misalignment still exists. Am I lookin at something wrong?

@DTorsani-WMF It may take some time to publish the changes to Netlify. I just checked and the Netlify link reflects the new changes. Can you try the link again?
https://1139140--wikimedia-codex.netlify.app/components/demos/accordion.html

Edit: According to Gerrit, the main test build succeeded at 1:37 pm EST, so I assume it was a bit too early to view the Netlify link before that time.

Accordion_flexbox.gif (480×320 px, 802 KB)

before:

image.png (1,082×454 px, 57 KB)

after patchset 5:

image.png (1,168×494 px, 63 KB)

I think this fits pretty well!

Change #1139140 merged by jenkins-bot:

[design/codex@main] Accordion: Use flexbox instead of positioning for action button

https://gerrit.wikimedia.org/r/1139140

Change #1191541 had a related patch set uploaded (by VolkerE; author: VolkerE):

[mediawiki/core@master] Update Codex from v2.3.1 to v2.3.2

https://gerrit.wikimedia.org/r/1191541

Change #1191541 merged by jenkins-bot:

[mediawiki/core@master] Update Codex from v2.3.1 to v2.3.2

https://gerrit.wikimedia.org/r/1191541

Volker_E subscribed.

@lwatson Is this ready to be resolved, or does Reader Growth need to continue to work with this ticket?

@Volker_E Yes, this task is ready to be resolved. The merged patch uses negative margins, and there was a suggestion to investigate an alternative approach to negative margins as a follow-up task.

Follow-up task: T405956: Accordion: investigate alternative approach to negative margins

lwatson updated the task description. (Show Details)