Skip to content

Conversation

@Mamaduka
Copy link
Member

What?

PR fixes incorrect <label for usage in FocalPointPicker component. 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

  1. Open a post or page.
  2. Add a Cover block and select media.
  3. Select the block so that the focal pointer picker is displayed.
  4. Confirm there are no errors in the browser console related to this component.

Testing Instructions for Keyboard

Same.

Screenshots or screencast

CleanShot 2025-07-22 at 12 45 41 CleanShot 2025-07-22 at 13 14 37

@Mamaduka Mamaduka self-assigned this Jul 22, 2025
@Mamaduka Mamaduka requested a review from ajitbohra as a code owner July 22, 2025 09:17
@Mamaduka Mamaduka added [Type] Bug An existing feature does not function as intended [Feature] UI Components Impacts or related to the UI component system [Package] Components /packages/components labels Jul 22, 2025
Comment on lines 251 to 253
// Displays text visually similar to label element.
// A temp hack for `@wordpress/no-base-control-with-label-without-id`.
id={ undefined }
Copy link
Member Author

@Mamaduka Mamaduka Jul 22, 2025

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:

cc @WordPress/gutenberg-components

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member Author

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.

@github-actions
Copy link

github-actions bot commented Jul 22, 2025

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: mirka <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link

github-actions bot commented Jul 22, 2025

Flaky tests detected in afadfb4.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/18864835466
📝 Reported issues:

@Mamaduka Mamaduka force-pushed the fix/focal-point-picker-html-for branch from f915349 to fc142e1 Compare July 28, 2025 07:38
@Mamaduka Mamaduka requested a review from mirka July 28, 2025 07:38
@mirka mirka requested a review from a team July 29, 2025 11:53
@Mamaduka Mamaduka force-pushed the fix/focal-point-picker-html-for branch from fc142e1 to 88540f1 Compare August 25, 2025 06:36
@Mamaduka Mamaduka force-pushed the fix/focal-point-picker-html-for branch from 88540f1 to da1f268 Compare September 7, 2025 18:27
@Mamaduka Mamaduka force-pushed the fix/focal-point-picker-html-for branch from da1f268 to 9f73e91 Compare October 27, 2025 15:37
Copy link
Member

@mirka mirka left a 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"
Copy link
Member

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;
Copy link
Member

@mirka mirka Oct 27, 2025

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 😅

@Mamaduka
Copy link
Member Author

Thanks for the review, @mirka!

Copy link
Member

@mirka mirka left a 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!

@Mamaduka Mamaduka merged commit 5803c39 into trunk Oct 28, 2025
35 checks passed
@Mamaduka Mamaduka deleted the fix/focal-point-picker-html-for branch October 28, 2025 13:51
@github-actions github-actions bot added this to the Gutenberg 22.0 milestone Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] UI Components Impacts or related to the UI component system [Package] Components /packages/components [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants