-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Components: Fix label markup for 'FocalPointPicker' #70835
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
Conversation
| // Displays text visually similar to label element. | ||
| // A temp hack for `@wordpress/no-base-control-with-label-without-id`. | ||
| id={ undefined } |
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.
The BaseControl supports the label prop without an id when it doesn't contain associated form elements as its children.
It appears that the ESLint rule (#14151) is too strict, resulting in incorrect markup. Here's another example:
gutenberg/packages/dataviews/src/dataform-controls/datetime.tsx
Lines 70 to 71 in 7a1f29f
| <BaseControl | |
| id={ id } |
cc @WordPress/gutenberg-components
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.
Cases like this with multiple fields usually call for fieldset/legend markup, not BaseControl. See for example the BorderControl implementation.
This is a rather common use case, so we're planning to prepare some components to make this easier though.
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.
Good point. I'll refactor FocalPointPicker to use fieldset markup.
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.
Here's the refactoring - f915349. Though, it may not be following current best practices of component systems.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Flaky tests detected in afadfb4. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/18864835466
|
f915349 to
fc142e1
Compare
fc142e1 to
88540f1
Compare
88540f1 to
da1f268
Compare
da1f268 to
9f73e91
Compare
mirka
left a comment
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.
Apologies for the delay 😱
| <BaseControl | ||
| { ...restProps } | ||
| __nextHasNoMarginBottom={ __nextHasNoMarginBottom } | ||
| __associatedWPComponentName="FocalPointPicker" |
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.
The deprecation notice for __nextHasNoMarginBottom was being handled through BaseControl, so we'll need to handle it separately. Could you add this back for me?
diff --git a/packages/components/src/focal-point-picker/index.tsx b/packages/components/src/focal-point-picker/index.tsx
index 03d75dfb6c..3485893860 100644
--- a/packages/components/src/focal-point-picker/index.tsx
+++ b/packages/components/src/focal-point-picker/index.tsx
@@ -13,6 +13,7 @@ import {
__experimentalUseDragging as useDragging,
useIsomorphicLayoutEffect,
} from '@wordpress/compose';
+import deprecated from '@wordpress/deprecated';
/**
* Internal dependencies
@@ -109,6 +110,14 @@ export function FocalPointPicker( {
const [ point, setPoint ] = useState( valueProp );
const [ showGridOverlay, setShowGridOverlay ] = useState( false );
+ if ( ! __nextHasNoMarginBottom ) {
+ deprecated( 'Bottom margin styles for wp.components.FocalPointPicker', {
+ since: '6.7',
+ version: '7.0',
+ hint: 'Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version.',
+ } );
+ }
+
const { startDrag, endDrag, isDragging } = useDragging( {
onDragStart: ( event ) => {
dragAreaRef.current?.focus();| export const Container = styled( View )` | ||
| border: 0; | ||
| padding: 0; | ||
| margin: 0; |
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.
I think this is missing a font-size: 13px that was in BaseControl, and it's affecting some spacing 😅
|
Thanks for the review, @mirka! |
mirka
left a comment
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.
Looks good, thank you!
What?
PR fixes incorrect
<label forusage inFocalPointPickercomponent. The label has no corresponding form element and should be treated as a visual label only.Notice the error report by the Chrome console.
Testing Instructions
Testing Instructions for Keyboard
Same.
Screenshots or screencast