Skip to content

Commit

Permalink
Bring the preview tab to the front when clicking the preview button
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Aug 15, 2018
1 parent 859a8d2 commit 0065ce9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/editor/src/components/post-preview-button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ export class PostPreviewButton extends Component {
this.previewWindow = window.open( '', this.getWindowTarget() );
}

// Ask the browser to bring the preview tab to the front
// This can work or not depending on the browser's user preferences
// https://html.spec.whatwg.org/multipage/interaction.html#dom-window-focus
this.previewWindow.focus();

// If there are no changes to autosave, we cannot perform the save, but
// if there is an existing preview link (e.g. previous published post
// autosave), it should be reused as the popup destination.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ describe( 'PostPreviewButton', () => {
write: jest.fn(),
close: jest.fn(),
},
focus: () => {},
};
} );

Expand Down

0 comments on commit 0065ce9

Please sign in to comment.