@wordpress/editor 14.8.1 → 14.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
- import { Component } from '@wordpress/element';
5
+ import { Component, createRef } from '@wordpress/element';
6
6
  import {
7
7
  Button,
8
8
  Spinner,
@@ -27,6 +27,20 @@ export class PostPublishPanel extends Component {
27
27
  constructor() {
28
28
  super( ...arguments );
29
29
  this.onSubmit = this.onSubmit.bind( this );
30
+ this.cancelButtonNode = createRef();
31
+ }
32
+
33
+ componentDidMount() {
34
+ // This timeout is necessary to make sure the `useEffect` hook of
35
+ // `useFocusReturn` gets the correct element (the button that opens the
36
+ // PostPublishPanel) otherwise it will get this button.
37
+ this.timeoutID = setTimeout( () => {
38
+ this.cancelButtonNode.current.focus();
39
+ }, 0 );
40
+ }
41
+
42
+ componentWillUnmount() {
43
+ clearTimeout( this.timeoutID );
30
44
  }
31
45
 
32
46
  componentDidUpdate( prevProps ) {
@@ -85,15 +99,9 @@ export class PostPublishPanel extends Component {
85
99
  />
86
100
  ) : (
87
101
  <>
88
- <div className="editor-post-publish-panel__header-publish-button">
89
- <PostPublishButton
90
- focusOnMount
91
- onSubmit={ this.onSubmit }
92
- forceIsDirty={ forceIsDirty }
93
- />
94
- </div>
95
102
  <div className="editor-post-publish-panel__header-cancel-button">
96
103
  <Button
104
+ ref={ this.cancelButtonNode }
97
105
  accessibleWhenDisabled
98
106
  disabled={ isSavingNonPostEntityChanges }
99
107
  onClick={ onClose }
@@ -103,6 +111,12 @@ export class PostPublishPanel extends Component {
103
111
  { __( 'Cancel' ) }
104
112
  </Button>
105
113
  </div>
114
+ <div className="editor-post-publish-panel__header-publish-button">
115
+ <PostPublishButton
116
+ onSubmit={ this.onSubmit }
117
+ forceIsDirty={ forceIsDirty }
118
+ />
119
+ </div>
106
120
  </>
107
121
  ) }
108
122
  </div>
@@ -68,12 +68,12 @@
68
68
  }
69
69
 
70
70
  .editor-post-publish-panel__header-publish-button {
71
- padding-right: $grid-unit-05;
71
+ padding-left: $grid-unit-05;
72
72
  justify-content: center;
73
73
  }
74
74
 
75
75
  .editor-post-publish-panel__header-cancel-button {
76
- padding-left: $grid-unit-05;
76
+ padding-right: $grid-unit-05;
77
77
  }
78
78
 
79
79
  .editor-post-publish-panel__header-published {
@@ -433,24 +433,24 @@ exports[`PostPublishPanel should render the pre-publish panel if post status is
433
433
  class="editor-post-publish-panel__header"
434
434
  >
435
435
  <div
436
- class="editor-post-publish-panel__header-publish-button"
436
+ class="editor-post-publish-panel__header-cancel-button"
437
437
  >
438
438
  <button
439
- aria-disabled="true"
440
- class="components-button editor-post-publish-button editor-post-publish-button__button is-primary is-compact"
439
+ class="components-button is-secondary is-compact"
441
440
  type="button"
442
441
  >
443
- Submit for Review
442
+ Cancel
444
443
  </button>
445
444
  </div>
446
445
  <div
447
- class="editor-post-publish-panel__header-cancel-button"
446
+ class="editor-post-publish-panel__header-publish-button"
448
447
  >
449
448
  <button
450
- class="components-button is-secondary is-compact"
449
+ aria-disabled="true"
450
+ class="components-button editor-post-publish-button editor-post-publish-button__button is-primary is-compact"
451
451
  type="button"
452
452
  >
453
- Cancel
453
+ Submit for Review
454
454
  </button>
455
455
  </div>
456
456
  </div>
@@ -586,24 +586,24 @@ exports[`PostPublishPanel should render the pre-publish panel if the post is not
586
586
  class="editor-post-publish-panel__header"
587
587
  >
588
588
  <div
589
- class="editor-post-publish-panel__header-publish-button"
589
+ class="editor-post-publish-panel__header-cancel-button"
590
590
  >
591
591
  <button
592
- aria-disabled="true"
593
- class="components-button editor-post-publish-button editor-post-publish-button__button is-primary is-compact"
592
+ class="components-button is-secondary is-compact"
594
593
  type="button"
595
594
  >
596
- Submit for Review
595
+ Cancel
597
596
  </button>
598
597
  </div>
599
598
  <div
600
- class="editor-post-publish-panel__header-cancel-button"
599
+ class="editor-post-publish-panel__header-publish-button"
601
600
  >
602
601
  <button
603
- class="components-button is-secondary is-compact"
602
+ aria-disabled="true"
603
+ class="components-button editor-post-publish-button editor-post-publish-button__button is-primary is-compact"
604
604
  type="button"
605
605
  >
606
- Cancel
606
+ Submit for Review
607
607
  </button>
608
608
  </div>
609
609
  </div>
@@ -783,24 +783,24 @@ exports[`PostPublishPanel should render the spinner if the post is being saved 1
783
783
  class="editor-post-publish-panel__header"
784
784
  >
785
785
  <div
786
- class="editor-post-publish-panel__header-publish-button"
786
+ class="editor-post-publish-panel__header-cancel-button"
787
787
  >
788
788
  <button
789
- aria-disabled="true"
790
- class="components-button editor-post-publish-button editor-post-publish-button__button is-primary is-compact"
789
+ class="components-button is-secondary is-compact"
791
790
  type="button"
792
791
  >
793
- Submit for Review
792
+ Cancel
794
793
  </button>
795
794
  </div>
796
795
  <div
797
- class="editor-post-publish-panel__header-cancel-button"
796
+ class="editor-post-publish-panel__header-publish-button"
798
797
  >
799
798
  <button
800
- class="components-button is-secondary is-compact"
799
+ aria-disabled="true"
800
+ class="components-button editor-post-publish-button editor-post-publish-button__button is-primary is-compact"
801
801
  type="button"
802
802
  >
803
- Cancel
803
+ Submit for Review
804
804
  </button>
805
805
  </div>
806
806
  </div>