Skip to content
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

Focus first section root block if no selected block and tabbing to zoom out canvas #65843

Merged
merged 2 commits into from
Oct 3, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Focus section root if no focus and tabbing to zoom out canvas
  • Loading branch information
jeryj committed Oct 2, 2024
commit 54ef45ad1d1171e319d1bc2119d0efc75ecec92f
Original file line number Diff line number Diff line change
@@ -19,10 +19,16 @@ export default function useTabNav() {
const focusCaptureBeforeRef = useRef();
const focusCaptureAfterRef = useRef();

const { hasMultiSelection, getSelectedBlockClientId, getBlockCount } =
useSelect( blockEditorStore );
const {
hasMultiSelection,
getSelectedBlockClientId,
getBlockCount,
getLastFocus,
getSectionRootClientId,
isZoomOut,
__unstableGetEditorMode,
} = unlock( useSelect( blockEditorStore ) );
const { setLastFocus } = unlock( useDispatch( blockEditorStore ) );
const { getLastFocus } = unlock( useSelect( blockEditorStore ) );
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this up to the other useSelect, as there shouldn't be a reason to use them in separate places.


// Reference that holds the a flag for enabling or disabling
// capturing on the focus capture elements.
@@ -45,6 +51,12 @@ export default function useTabNav() {
)
.focus();
}
}
// In "compose" mode without a selected ID, we want to place focus on the section root when tabbing to the canvas.
else if ( __unstableGetEditorMode() === 'zoom-out' && isZoomOut() ) {
container.current
.querySelector( `[data-block="${ getSectionRootClientId() }"]` )
.focus();
} else {
const canvasElement =
container.current.ownerDocument === event.target.ownerDocument
@@ -61,7 +73,6 @@ export default function useTabNav() {
const next = isBefore
? tabbables[ 0 ]
: tabbables[ tabbables.length - 1 ];

next.focus();
}
}

Unchanged files with check annotations Beta

const url = this.storageState!.rootURL + relativePath;
try {
const response = await this.request.fetch( url, {

Check failure on line 119 in packages/e2e-test-utils-playwright/src/request-utils/rest.ts

GitHub Actions / Playwright - 6

[chromium] › widgets/customizing-widgets.spec.js:577:2 › Widgets Customizer › preserves content in the Custom HTML block

1) [chromium] › widgets/customizing-widgets.spec.js:577:2 › Widgets Customizer › preserves content in the Custom HTML block Error: apiRequestContext.fetch: socket hang up Call log: - → GET http://localhost:8889/index.php?rest_route=/wp/v2/sidebars - user-agent: Playwright/1.47.0 (x64; ubuntu 22.04) node/20.17 CI/1 - accept: */* - accept-encoding: gzip,deflate,br - X-WP-Nonce: 2e933663c5 - cookie: wordpress_test_cookie=WP%20Cookie%20check; wordpress_logged_in_23778236db82f19306f247e20a353a99=admin%7C1728070471%7C07HQSh3drZdefSOrBngaN76o5q70Qwp0zBBx13vaFqF%7Ccb2153ee7a01299986b8339266adb9bb04bcd29c572f759097a9d116c0177bcc; wp-settings-time-1=1727897961 at ../../../packages/e2e-test-utils-playwright/src/request-utils/rest.ts:119 117 | 118 | try { > 119 | const response = await this.request.fetch( url, { | ^ 120 | ...fetchOptions, 121 | failOnStatusCode: false, 122 | headers: { at RequestUtils.rest (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/request-utils/rest.ts:119:39) at RequestUtils.deleteAllWidgets (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/request-utils/widgets.js:9:8) at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/widgets/customizing-widgets.spec.js:37:22
...fetchOptions,
failOnStatusCode: false,
headers: {