Skip to content

Commit

Permalink
Close button uses <a> tag
Browse files Browse the repository at this point in the history
This matches the previous behaviour before overriding the button. This
allows users to open link in new tab.
  • Loading branch information
p-jackson committed Jul 1, 2020
1 parent 3f5ad55 commit 5f1cd88
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -581,23 +581,29 @@ function handleCloseEditor( calypsoPort ) {
);
} );

const dispatchAction = () => {
const dispatchAction = ( e ) => {
if ( ! applyFilters( 'a8c.wpcom-block-editor.shouldCloseEditor', true ) ) {
return;
}

e.preventDefault();

doAction( 'a8c.wpcom-block-editor.closeEditor' );
};

registerPlugin( 'a8c-wpcom-block-editor-close-button-override', {
render: function CloseWpcomBlockEditor() {
const [ closeUrl, setCloseUrl ] = useState( calypsoifyGutenberg.closeUrl );
const [ label, setLabel ] = useState( calypsoifyGutenberg.closeButtonLabel );

useEffect( () => {
addAction(
'updateCloseButtonOverrides',
'a8c/wpcom-block-editor/CloseWpcomBlockEditor',
( data ) => setLabel( data.label )
( data ) => {
setCloseUrl( data.closeUrl );
setLabel( data.label );
}
);
return () =>
removeAction(
Expand All @@ -611,10 +617,11 @@ function handleCloseEditor( calypsoPort ) {
<Button
// eslint-disable-next-line wpcalypso/jsx-classname-namespace
className="edit-post-fullscreen-mode-close wpcom-block-editor__close-button"
href={ closeUrl }
icon={ wordpress }
iconSize={ 36 }
onClick={ dispatchAction }
label={ label }
onClick={ dispatchAction }
/>
</MainDashboardButton>
);
Expand Down

0 comments on commit 5f1cd88

Please sign in to comment.