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

Move Link Control action buttons into lower settings area #47309

Merged
merged 4 commits into from
Jan 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 30 additions & 23 deletions packages/block-editor/src/components/link-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ function LinkControl( {
// See https://github.com/WordPress/gutenberg/pull/33849/#issuecomment-932194927.
const showTextControl = hasLinkValue && hasTextControl;

const isEditing = ( isEditingLink || ! value ) && ! isCreatingPage;
return (
<div
tabIndex={ -1 }
Expand All @@ -286,7 +287,7 @@ function LinkControl( {
</div>
) }

{ ( isEditingLink || ! value ) && ! isCreatingPage && (
{ isEditing && (
<>
<div
className={ classnames( {
Expand Down Expand Up @@ -335,19 +336,6 @@ function LinkControl( {
{ errorMessage }
</Notice>
) }
<div className="block-editor-link-control__search-actions">
<Button
variant="primary"
onClick={ handleSubmit }
className="xblock-editor-link-control__search-submit"
disabled={ currentInputIsEmpty } // Disallow submitting empty values.
>
{ __( 'Apply' ) }
</Button>
<Button variant="tertiary" onClick={ handleCancel }>
{ __( 'Cancel' ) }
</Button>
</div>
</>
) }

Expand All @@ -362,15 +350,34 @@ function LinkControl( {
/>
) }

{ showSettingsDrawer && (
<div className="block-editor-link-control__tools">
<LinkControlSettingsDrawer
value={ value }
settings={ settings }
onChange={ onChange }
/>
</div>
) }
<div className="block-editor-link-control__drawer">
{ showSettingsDrawer && (
<div className="block-editor-link-control__tools">
<LinkControlSettingsDrawer
value={ value }
settings={ settings }
onChange={ onChange }
/>
</div>
) }

{ isEditing && (
<div className="block-editor-link-control__search-actions">
<Button
variant="primary"
onClick={ handleSubmit }
className="xblock-editor-link-control__search-submit"
disabled={ currentInputIsEmpty } // Disallow submitting empty values.
>
{ __( 'Apply' ) }
</Button>
<Button variant="tertiary" onClick={ handleCancel }>
{ __( 'Cancel' ) }
</Button>
</div>
) }
</div>

{ renderControlBottom && renderControlBottom() }
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ $preview-image-height: 140px;
display: flex;
flex-direction: row-reverse; // put "Cancel" on the left but retain DOM order.
justify-content: flex-start;
margin: $grid-unit-20; // allow margin collapse for vertical spacing.
gap: $grid-unit-10;
}

Expand Down Expand Up @@ -427,9 +426,10 @@ $preview-image-height: 140px;
padding: 10px;
}

.block-editor-link-control__tools {
.block-editor-link-control__drawer {
display: flex;
align-items: center;
justify-content: space-between;
border-top: $border-width solid $gray-300;
margin: 0;
padding: $grid-unit-20;
Expand Down
10 changes: 3 additions & 7 deletions packages/e2e-tests/specs/editor/various/links.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ describe( 'Links', () => {

// Navigate to and toggle the "Open in new tab" checkbox.
await page.keyboard.press( 'Tab' );
await page.keyboard.press( 'Tab' );
await page.keyboard.press( 'Tab' );
await page.keyboard.press( 'Space' );

// Toggle should still have focus and be checked.
Expand All @@ -135,8 +133,7 @@ describe( 'Links', () => {
expect( await getEditedPostContent() ).toMatchSnapshot();

// Tab back to the Submit and apply the link.
await pressKeyWithModifier( 'shift', 'Tab' );
await pressKeyWithModifier( 'shift', 'Tab' );
await page.keyboard.press( 'Tab' );
await page.keyboard.press( 'Enter' );

// The link should have been inserted.
Expand Down Expand Up @@ -529,8 +526,6 @@ describe( 'Links', () => {

// Navigate to and toggle the "Open in new tab" checkbox.
await page.keyboard.press( 'Tab' );
await page.keyboard.press( 'Tab' );
await page.keyboard.press( 'Tab' );
await page.keyboard.press( 'Space' );

// Confirm that focus was not prematurely returned to the paragraph on
Expand All @@ -539,7 +534,8 @@ describe( 'Links', () => {

// Close dialog. Expect that "Open in new tab" would have been applied
// immediately.
await page.keyboard.press( 'Tab' );

await pressKeyWithModifier( 'shift', 'Tab' );
await page.keyboard.press( 'Enter' );

// Wait for Gutenberg to finish the job.
Expand Down