Make WordPress Core

Opened 5 years ago

Closed 5 months ago

#48691 closed defect (bug) (invalid)

Twenty Twenty: Audio block alignment issue

Reported by: kharisblank's profile kharisblank Owned by: nielslange's profile nielslange
Milestone: Priority: normal
Severity: normal Version: 5.3
Component: Bundled Theme Keywords: has-screenshots 2nd-opinion close
Focuses: ui, css Cc:

Description

Hello The Amazing Team of Twenty Twenty,

I am playing around with audio block and found alignment issue. See the attached image that best explains it better.

https://i.imgur.com/57TRzlj.png

I have searched previous tickets and didn't find it has been reported. I hope this isn't duplicate ticket.

Best,
Kharis

Attachments (4)

audio-align-right-issue.png (25.9 KB) - added by kharisblank 5 years ago.
Alignment issue when "Align Right" enabled on Audio Block. Here is how web browser's inspector shows.
audio-align-right-produces-horizontal-scroll.gif (363.5 KB) - added by kharisblank 5 years ago.
Horizontal scroll bar appears when "Align Right" enabled on Audio Block.
fix-audio-block-alignment.1.diff (558 bytes) - added by kharisblank 5 years ago.
My first attempt to patch this bug. Still need some testings.
SCR-20240722-llic.png (71.9 KB) - added by karmatosed 5 months ago.
Centering not being reflected in caption

Download all attachments as: .zip

Change History (24)

#1 follow-up: @nielslange
5 years ago

  • Keywords needs-testing removed

@kharisblank Thanks for reporting this issue. Could you provide more information regarding this issue? The following template might be helpful.


Steps to reproduce:

  1. ...
  2. ...
  3. ...

Expected behaviour:

  • ...

Current behaviour:

  • ...

#2 @nielslange
5 years ago

  • Keywords reporter-feedback added

#3 in reply to: ↑ 1 @kharisblank
5 years ago

Replying to nielslange:

You're welcome!

Steps to reproduce:

  1. Insert an audio block and set a caption
  2. Enable "Align Center"

https://i.imgur.com/R726wo0.gif

https://i.imgur.com/3xMgZob.gif

Expected behaviour:

https://i.imgur.com/xFWTQiY.png

Audio block along with its caption should be center aligned when vieweing the actual post.

Current behaviour:

It's already centered in block editor. But it isn't when vieweing the actual post page.

https://i.imgur.com/qE3GAap.png


When I chose "Align Right", the audio block goes too far right and overlaps the main content's container. It's resulting horizontal window scroll bar at the bottom appears. See the below screencast:

https://i.imgur.com/Ya3lk7R.gif

Expected behaviour for this:

  • Audio block should not overlapping main content's container
  • Align right the caption

Let me know if there's anything else I should explain more.

Best,
Kharis

@kharisblank
5 years ago

Alignment issue when "Align Right" enabled on Audio Block. Here is how web browser's inspector shows.

@kharisblank
5 years ago

Horizontal scroll bar appears when "Align Right" enabled on Audio Block.

#4 follow-up: @nielslange
5 years ago

  • Keywords reporter-feedback removed
  • Owner set to nielslange
  • Status changed from new to assigned

@kharisblank That's a fantastic issue report! Very detailed and very well done. Do you like to create a patch for this issue?

#5 @ianbelanger
5 years ago

  • Milestone changed from Awaiting Review to 5.3.1

#6 in reply to: ↑ 4 @kharisblank
5 years ago

Replying to nielslange:

Do you like to create a patch for this issue?

I will try to make a patch for this and will submit it soon.

Regards,
Kharis

@kharisblank
5 years ago

My first attempt to patch this bug. Still need some testings.

#8 @poena
5 years ago

Hi
I am able to reproduce the problem.

I actually think the centering of the text needs be fixed in the block editor styles and not in the themes.
For example, the block editor styles the figcaption for the video block:

.wp-block-video.aligncenter{text-align:center}

but this is missing for the audio block.

Looking at Twenty Nineteen, the theme itself always centers the figcaption for the audio block, no matter
what the alignment of the block is.


I believe that the min-width part of the patch needs to be removed, because the player is much wider in the editor than it is in the front, what do you think?

Last edited 5 years ago by poena (previous) (diff)

#9 @nielslange
5 years ago

@kharisblank Thanks for creating the patch. I'd agree with @poena that the styles to fix this issue should be applied to /assets/css/editor-style-block.css rather than to style.css.

I also believe that the width of the audio elements should only be changed when needed, but not by default. While I can see the progress bar of the audio track on https://qmaubeli.online/patch-test-audio-center-align/, when viewing the audio block on https://qmaubeli.online/patch-test-audio-left-align/ and https://qmaubeli.online/patch-test-audio-right-align/ the progress bar turns into a single dot which makes it impossible to navigate within the audio file.

#10 @kharisblank
5 years ago

Hi all,

I'd agree with @poena as well. .aligncenter is universal class name. A theme should not redefine center alignmet for it.

@nielslange this is what happens without this code.

.wp-block-audio.alignleft audio,
.wp-block-audio.alignright audio {
  width: auto;
  min-width: 100%;
  max-width: 100%;
}

Best,
Kharis

#11 @nielslange
5 years ago

@kharisblank Can you think of another solution? 😉

#12 @kharisblank
5 years ago

@poena

I believe that the min-width part of the patch needs to be removed, because the player is much wider in the editor than it is in the front, what do you think?

I am not quite sure about this. Because minimum width is defined in below lines of code in block library CSS of the core.

.wp-block-audio audio {
  width: 100%;
  min-width: 300px;
}

However this breaking right alignment on Twenty Twenty. Without extra custom width min-width: 100%;, this is what I am getting.

@nielslange

Can you think of another solution?

Let me try it.

Best,
Kharis

#13 @kharisblank
5 years ago

I used this improved code (only for right alignment at this time). In this code I attempted to maintain the HTML5 audio minimum width to avoid unaccessible audio controls. By default its width is 270px on Firefox and 300px on Chrome. Refer to W3S.

.entry-content > .wp-block-audio.alignright {
   max-width: 100%;
}

@media only screen and (min-width: 480px) {
  .entry-content > .wp-block-audio.alignright {
    min-width: 0;
    padding-right: 2rem;
  }
}

@media only screen and (min-width: 1000px) {
  .entry-content > .wp-block-audio.alignright {
    position: static;
    margin-right: 0;
    left: auto;
    max-width: 100%;
  }
}

@media only screen and (min-width: 1280px) {
  .entry-content > .wp-block-audio.alignright {
    max-width: unset;
    left: auto;
  }
}

This is what I am getting (on Firefox). I tested with Chrome as well and it behaves the same way.

https://i.imgur.com/qYNadRs.gif

I believe this code still need some testings at your end. I'd like to hear your thought on this.

Extra question:

Does anybody know why lesser width of the audio always appears like this on Safari, even when my custom code removed?

https://i.imgur.com/maC1Wno.png

Version 2, edited 5 years ago by kharisblank (previous) (next) (diff)

This ticket was mentioned in Slack in #core by audrasjb. View the logs.


5 years ago

#15 @ianbelanger
5 years ago

  • Keywords needs-refresh added
  • Milestone changed from 5.3.1 to 5.4

The patch does somewhat fix the issue, but I think it needs to be refreshed and tested more, so I am punting this to 5.4

#16 @ianbelanger
5 years ago

  • Milestone changed from 5.4 to Future Release

This still has not been refreshed so I am punting out of 5.4.

#17 @poena
11 months ago

I can reproduce this in WordPress 6.4.2, but only when the audio block is full width.

For the full width block, the caption has a set width and max-width on the front but not in the editor. The result is that on the front, the text is left aligned, but only as wide as the content width.

Personally I think the alignment would be OK if only the editor and front matched.

Audio block captions at all other alignments are to the left in both the editor and the front.

#18 @karmatosed
5 months ago

  • Keywords 2nd-opinion added

I am testing this today and curiously on wide or non-wide the same both at the front and back is true, centering doesn't work for the caption. My recommendation would be to either keep it this way or to bring in centering for both editors.

@karmatosed
5 months ago

Centering not being reflected in caption

#19 @karmatosed
5 months ago

  • Keywords close added; needs-patch needs-refresh removed

For now, I am going to recommend this is closed unless we get a PR that specifically targets the center alignment on both front and back editor. It does match in testing, it's just not centering the caption. We absolutely can change this if others feel different though, but I feel progressing this onward is useful.

#20 @karmatosed
5 months ago

  • Milestone Future Release deleted
  • Resolution set to invalid
  • Status changed from assigned to closed

I am going to follow through closing this, thank you everyone.

Note: See TracTickets for help on using tickets.