-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Add back button for isolated template part editor #34732
Merged
kevin940726
merged 8 commits into
trunk
from
add/isolated-template-part-editor-back-button
Sep 28, 2021
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
62832c0
Add back button for isolated template part editor
kevin940726 ed98415
Fix unit tests
kevin940726 9b3eea0
Add push template part
kevin940726 df94d4b
Use push on edit button and simplify label
kevin940726 34ce49b
Only show background in focus mode
kevin940726 81380b5
Fix unit tests
kevin940726 3e2326b
Always show focus mode in template part editor
kevin940726 75ac321
Remove useTemplateTitle
kevin940726 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
packages/edit-site/src/components/block-editor/back-button.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { Button } from '@wordpress/components'; | ||
import { arrowLeft } from '@wordpress/icons'; | ||
import { useSelect, useDispatch } from '@wordpress/data'; | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { store as editSiteStore } from '../../store'; | ||
|
||
function BackButton() { | ||
const { isTemplatePart, previousTemplateId } = useSelect( ( select ) => { | ||
const { getEditedPostType, getPreviousEditedPostId } = select( | ||
editSiteStore | ||
); | ||
|
||
return { | ||
isTemplatePart: getEditedPostType() === 'wp_template_part', | ||
previousTemplateId: getPreviousEditedPostId(), | ||
}; | ||
}, [] ); | ||
const { goBack } = useDispatch( editSiteStore ); | ||
|
||
if ( ! isTemplatePart || ! previousTemplateId ) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Button | ||
className="edit-site-visual-editor__back-button" | ||
icon={ arrowLeft } | ||
onClick={ () => { | ||
goBack(); | ||
} } | ||
> | ||
{ __( 'Back' ) } | ||
</Button> | ||
); | ||
} | ||
|
||
export default BackButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably should auto focus on this element when navigating to the isolated editor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm. Could we focus
.edit-site-visual-editor
? That way pressing Tab once focuses the close button. This matches how other modal interfaces work in the block editor e.g. opening Preferences.cc. @tellthemachines who is smarter than I am at this kind of stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not 100% sure what's going on here, but this is what I'm seeing:
When tabbing through the page, starting from the header, the back button is focusable in the normal tab order as long as nothing inside the editor is selected. This means that if I tab to the button, and tab once more, landing on the first block in the editor area, I'm unable to Shift+Tab back to the button. In addition, the shortcut to navigate between landmark areas (Ctrl+`) doesn't seem to work in the site editor, so there's no way to get back to that button.
I'd expect to be able to Shift+Tab back to the button from the editor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I couldn't figure it out either. It seems like pressing Shift + Tab goes back to the editor header in site editor. No idea if it's a browser thing or it's handled somewhere else 🤔. It's not that normal since the editor is in an iframe. Anyone has any idea how to fix this?