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

Removing wrapper div from the categories block #9798

Merged
merged 1 commit into from
Sep 11, 2018

Conversation

kjellr
Copy link
Contributor

@kjellr kjellr commented Sep 11, 2018

Fixes #9411

Previously, the categories block was rendered inside a div, while other list-based blocks (archives, latest posts, list, etc.) were not. This update removes the div wrapper for consistency.

Previously, this block would render like this:

<!-- Categories Block -->
<div class="wp-block-categories wp-block-categories-list aligncenter">
  <ul>
    <li class="cat-item cat-item-1"><a href="#">Category</a></li>
    <li class="cat-item cat-item-2"><a href="#">Category</a></li>
    <li class="cat-item cat-item-3"><a href="#">Category</a></li>
  </ul>
</div>

But this change updates that to:

<!-- Categories Block -->
<ul class="wp-block-categories wp-block-categories-list aligncenter">
  <li class="cat-item cat-item-1"><a href="#">Category</a></li>
  <li class="cat-item cat-item-2"><a href="#">Category</a></li>
  <li class="cat-item cat-item-3"><a href="#">Category</a></li>
</ul>

We still need the wrapper div if this is shown as a dropdown, so this doesn't effect that. Seems like a simple change, and doesn't seem to require any css updates.

Previously, the categories block was rendered inside a div, while other list-based blocks (archives, latest posts, list, etc.) were not. This update removes the div wrapper for consistency.
@kjellr kjellr added the [Feature] Blocks Overall functionality of blocks label Sep 11, 2018
@kjellr kjellr self-assigned this Sep 11, 2018
@kjellr kjellr requested review from mtias and a team September 11, 2018 15:21
Copy link
Member

@tofumatt tofumatt left a comment

Choose a reason for hiding this comment

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

Works for me. Technically it's a breaking change for anyone styling things if they happened to rely on it being a div, but that seems silly anyway 😄 . Dunno how we tend to handle that with markup, but the change itself looks good.

@ZebulanStanphill
Copy link
Member

While we're updating the Categories block markup, shouldn't it also use an <ol> instead of a <ul>? The categories are listed in an order, so an <ol> is more appropriate, is it not?

@kjellr
Copy link
Contributor Author

kjellr commented Sep 11, 2018

Technically it's a breaking change for anyone styling things if they happened to rely on it being a div, but that seems silly anyway 😄 . Dunno how we tend to handle that with markup, but the change itself looks good.

Thanks, @tofumatt — I agree that this seems like it'd be a very small fraction of themes. If anything, I've mostly heard from theme authors who dislike that these are inconsistent. 😄 So I think we're good to go.

While we're updating the Categories block markup, shouldn't it also use an <ol> instead of a <ul>? The categories are listed in an order, so an <ol> is more appropriate, is it not?

@ZebulanStanphill: <ol> would render a numbered list, but I can't think of a reason for categories to be associated with a number. <ul> seems more appropriate to me in this case.

@kjellr kjellr added this to the 3.9 milestone Sep 11, 2018
@kjellr kjellr merged commit a0dfb14 into master Sep 11, 2018
@kjellr kjellr deleted the update/categories-block-wrapper branch September 11, 2018 19:27
@ZebulanStanphill
Copy link
Member

@kjellr <ol> is not just for numbered lists. It is for any kind of ordered list. The Latest Comments block uses an <ol>, for example. You just have to style the <ol> to not show the numbers.

@chrisvanpatten
Copy link
Contributor

@ZebulanStanphill I think the difference here is that if the order of the categories were to change, there would be no change in meaning. However, changing the order of comments would change the way they're interpreted, since comments may reply to each other or provide context as a discussion continues.

Per the spec:

The ol element represents a list of items, where the items have been intentionally ordered, such that changing the order would change the meaning of the document.

(Emphasis is mine)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Blocks Overall functionality of blocks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants