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

Fix mismatching link control action buttons visual order and DOM order #56042

Merged
merged 3 commits into from
Nov 13, 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
4 changes: 2 additions & 2 deletions packages/block-editor/src/components/link-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,14 @@ If passed, children are rendered after the input.

```jsx
<LinkControlSearchInput>
<div className="block-editor-link-control__search-actions">
<HStack justify="right">
<Button
type="submit"
label={ __( 'Submit' ) }
icon={ keyboardReturn }
className="block-editor-link-control__search-submit"
/>
</div>
</HStack>
</LinkControlSearchInput>
```

Expand Down
21 changes: 15 additions & 6 deletions packages/block-editor/src/components/link-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import classnames from 'classnames';
/**
* WordPress dependencies
*/
import { Button, Spinner, Notice, TextControl } from '@wordpress/components';
import {
Button,
Spinner,
Notice,
TextControl,
__experimentalHStack as HStack,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { useRef, useState, useEffect } from '@wordpress/element';
import { focus } from '@wordpress/dom';
Expand Down Expand Up @@ -467,7 +473,13 @@ function LinkControl( {
) }

{ showActions && (
<div className="block-editor-link-control__search-actions">
<HStack
justify="right"
className="block-editor-link-control__search-actions"
>
<Button variant="tertiary" onClick={ handleCancel }>
{ __( 'Cancel' ) }
</Button>
<Button
variant="primary"
onClick={ isDisabled ? noop : handleSubmit }
Expand All @@ -476,10 +488,7 @@ function LinkControl( {
>
{ __( 'Save' ) }
</Button>
<Button variant="tertiary" onClick={ handleCancel }>
{ __( 'Cancel' ) }
</Button>
</div>
</HStack>
) }

{ renderControlBottom && renderControlBottom() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,7 @@ $preview-image-height: 140px;
}

.block-editor-link-control__search-actions {
display: flex;
flex-direction: row-reverse; // put "Cancel" on the left but retain DOM order.
justify-content: flex-start;
gap: $grid-unit-10;
padding: $grid-unit-10 $grid-unit-20 $grid-unit-20;
order: 20;
}

.block-editor-link-control__search-results-wrapper {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
&.has-siblings {
border-top: $border-width solid $gray-900;
margin-top: $grid-unit-10;
padding-bottom: $grid-unit-10;
}

.block-editor-media-replace-flow__image-url-label {
Expand Down Expand Up @@ -55,8 +56,7 @@
}

.block-editor-link-control__search-actions {
top: 0; // cancel default top positioning
right: 4px;
padding: $grid-unit-10 0 0;
}
}
}
Expand Down
1 change: 0 additions & 1 deletion packages/edit-post/src/components/visual-editor/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
font-size: $default-font-size;
padding: 6px 12px;

&.is-tertiary,
&.has-icon {
padding: 6px;
}
Expand Down
Loading