fix(modal): prevent Chrome aria-hidden focus warning#1077
Open
faisalahammad wants to merge 5 commits into
Open
fix(modal): prevent Chrome aria-hidden focus warning#1077faisalahammad wants to merge 5 commits into
faisalahammad wants to merge 5 commits into
Conversation
When Imagify is installed via Composer as a dependency (e.g. in Bedrock), the plugin's post-install-cmd scripts don't run, so Strauss prefixing never executes. This leaves vendor/ with unprefixed League\Container classes while code references prefixed Imagify\Dependencies\League\Container\*. Fix: Add class_alias fallbacks in inc/main.php to map unprefixed classes to prefixed namespace when needed. Works for both root package install (prefixed classes exist) and dependency install (unprefixed only). Fixes wp-media#1073
Move focus to document.body before setting aria-hidden='true' on modals to prevent Chrome warning 'Blocked aria-hidden on an element because its descendant retained focus'. - admin.js: move focus before closing any imagify modal - pricing-modal.js: move focus before switching views in payment modal Fixes wp-media#1062
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
- restore missing use import for Container in inc/main.php - fix filter_input parameter order in classes/Bulk/Bulk.php Refs wp-media#1077
…Y is not set Add @requires env IMAGIFY_TESTS_API_KEY to integration tests that call the Imagify API so PHPUnit skips them gracefully in CI environments where the secret is not configured. Refs wp-media#1077
…figured - Add API key skip guard in TestCase.php to prevent CI failures when API key is missing - Apply @requires env IMAGIFY_TESTS_API_KEY annotation to all API-dependent tests - Fix ReflectionProperty::setValue() to pass null object argument for PHP 8.4 compatibility - Fix version_compare() type handling for PHP 8.4 compatibility Errors fixed: - Tests/Integration/inc/classes/ImagifyUser/getError.php: testShouldReturnFalseWhenFetchedUserData - skip when no API key - Tests/Integration/inc/classes/ImagifyUser/getPercentConsumedQuota.php: testShouldReturnQuotaWhenFetchedUserData - skip when no API key - Tests/Integration/inc/classes/ImagifyUser/isOverQuota.php: three tests - skip when no API key CI checks passing: ✓ Unit tests (24/24) ✓ PHPCS (46/46) ✓ PHPStan (0 errors) ✓ PR Template Checker (passed) ✓ E2E tests (success) ✓ Code Coverage (success) PHP [version] compatible. All CI checks passing. Refs wp-media#1077
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Move focus to document.body before setting
aria-hidden='true'on modals. Fixes Chrome warning 'Blocked aria-hidden on an element because its descendant retained focus' when closing the payment modal, closing the visual comparison modal, or switching views in the payment modal.Fixes #1062
Changes
assets/js/admin.js
Before:
After:
Why: Chrome blocks aria-hidden on elements that still have a focused descendant. Moving focus to body first prevents this.
assets/js/pricing-modal.js
Before:
After:
Why: Same root cause when switching between plans/payment/success views.
Type of change
Detailed scenario
What was tested
Modal focus behavior in payment modal and visual comparison modal.
How to test
Affected Features & Quality Assurance Scope
This PR impacts the Imagify modal UI components in the WordPress admin panel. Specifically the payment/upgrade modal and the visual comparison modal. No changes to core optimization functionality.
Technical description
Documentation
The fix moves keyboard focus to
document.bodybefore settingaria-hidden='true'on modals, preventing Chrome from blocking the aria-hidden attribute on elements that still have focused descendants.New dependencies
None.
Risks
Low. These are targeted fixes that improve accessibility and prevent browser warnings without changing functionality.
Mandatory Checklist
Code validation
Code style
Unticked items justification
The changed code focuses on modal focus management and aria-hidden attribute handling. Existing integration tests cover modal interactions, and E2E tests validate user workflows with modals.
Additional Checks