Skip to content

Commit

Permalink
Fix mismatching link control action buttons visual order and DOM order (
Browse files Browse the repository at this point in the history
#56042)

* Fix visual and dom order by using HStack.

* Fix padding of tertiary buttons within the visual editor.

* Fix top padding in media replace popover.
  • Loading branch information
afercia committed Nov 13, 2023
1 parent e1c30f8 commit fc8997e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
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
5 changes: 0 additions & 5 deletions packages/block-editor/src/components/link-control/style.scss
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

1 comment on commit fc8997e

@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 fc8997e.
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/6847633202
📝 Reported issues:

Please sign in to comment.