-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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: Frontend Category Label + Make Category and Archive Labels Visible #11219
Changes from all commits
7ec451e
bef9132
7a92703
73bf117
13d2c62
f8aaed9
1fbf486
8303b79
aeced83
0ac7a16
434cfb2
4cee796
718af2c
499096f
aabce13
b85f3e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
.block-editor ul.wp-block-archives { | ||
padding-left: 2.5em; | ||
} | ||
|
||
.block-editor .wp-block-archives__label { | ||
display: block; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,7 +68,9 @@ function render_block_core_archives( $attributes ) { | |
|
||
$label = esc_attr( $label ); | ||
|
||
$block_content = '<label class="screen-reader-text" for="' . $dropdown_id . '">' . $title . '</label> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this necessary? Per #10871 (comment) it looks like we may want to keep this class. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I think I got a little eager with this PR, but essentially I felt it was necessary to make the labels visible because it will provide better context to all users. If we can get some design feedback, I can easily revert the removal of these classes. There was some discussion about this in the original issue for this. Maybe @afercia can also speak to why others felt it made sense to make the label visible. |
||
$label_class = 'wp-block-archives__label'; | ||
|
||
$block_content = '<label class="' . $label_class . '" for="' . $dropdown_id . '">' . $title . '</label> | ||
<select id="' . $dropdown_id . '" name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;"> | ||
<option value="">' . $label . '</option>' . $archives . '</select>'; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.wp-block-archives-dropdown { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This class is never actually assigned to the This note applies to the categories block as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm I thought these were being added with the below code:
I'll take a look and see what I find out There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like it is being applied but it has a low specificity compared to a bunch of other selectors. |
||
margin-bottom: 1em; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,7 @@ | |
margin-top: 6px; | ||
} | ||
} | ||
|
||
.block-editor .wp-block-categories__label { | ||
display: block; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,9 @@ function render_block_core_categories( $attributes ) { | |
$wrapper_markup = '<div class="%1$s">%2$s</div>'; | ||
$items_markup = wp_dropdown_categories( $args ); | ||
$type = 'dropdown'; | ||
$title = esc_html( __( 'Categories' ) ); | ||
$label_class = 'wp-block-categories-label'; | ||
$items_markup = '<label class="' . $label_class . '" for="' . $id . '">' . $title . '</label> ' . $items_markup; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe https://developer.wordpress.org/reference/functions/esc_html__/ |
||
|
||
if ( ! is_admin() ) { | ||
$wrapper_markup .= build_dropdown_script_block_core_categories( $id ); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,7 @@ | |
margin-left: 2em; | ||
} | ||
} | ||
|
||
.wp-block-categories-dropdown { | ||
margin-bottom: 1em; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this not also be
display: block;
on the front-end?This note applies to the categories block as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the time I think I wanted these to be as least opinionated as possible in themes but I can make these changes to render the controls in the same manner on the front end.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So why is it part of the editor styles in the first place?