Skip to content

Commit

Permalink
Use checkbox for Open in new tab within Link Control (#50961)
Browse files Browse the repository at this point in the history
* Use checkbox control

* Align controls

* Fix toggle replaced with checkbox
  • Loading branch information
getdave authored May 26, 2023
1 parent 156ac69 commit e0f300d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/block-editor/src/components/link-control/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { ToggleControl, VisuallyHidden } from '@wordpress/components';
import { CheckboxControl, VisuallyHidden } from '@wordpress/components';

const noop = () => {};

Expand All @@ -19,7 +19,7 @@ const LinkControlSettings = ( { value, onChange = noop, settings } ) => {
};

const theSettings = settings.map( ( setting ) => (
<ToggleControl
<CheckboxControl
__nextHasNoMarginBottom
className="block-editor-link-control__setting"
key={ setting.id }
Expand Down
5 changes: 5 additions & 0 deletions packages/block-editor/src/components/link-control/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,11 @@ $preview-image-height: 140px;
.block-editor-link-control__setting {
margin-bottom: $grid-unit-20;

// Cancel left margin inherited from WP Admin Forms CSS.
input {
margin-left: 0;
}

&.block-editor-link-control__setting:last-child {
margin-bottom: 0;
}
Expand Down
6 changes: 4 additions & 2 deletions packages/e2e-tests/specs/editor/various/links.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ describe( 'Links', () => {

// Toggle should still have focus and be checked.
await page.waitForSelector(
':focus:checked.components-form-toggle__input'
':focus:checked.components-checkbox-control__input'
);

// Ensure that the contents of the post have not been changed, since at
Expand Down Expand Up @@ -539,7 +539,9 @@ describe( 'Links', () => {

// Confirm that focus was not prematurely returned to the paragraph on
// a changing value of the setting.
await page.waitForSelector( ':focus.components-form-toggle__input' );
await page.waitForSelector(
':focus.components-checkbox-control__input'
);

// Submit link. Expect that "Open in new tab" would have been applied
// immediately.
Expand Down

1 comment on commit e0f300d

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected in e0f300d.
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/5090941737
📝 Reported issues:

Please sign in to comment.