[Grid][Filter] - re apply focus to parent filter container when filter was added so we can apply filters on enter #2143
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.
Changes in this pull request
Resolves #2141
Additional info
This pull request introduces enhancements to focus management in the filter sidebar, improving accessibility and user experience when interacting with dynamic field filters. The main changes involve adding a context-based focus restoration mechanism and refactoring several filter components to utilize it. Additionally, updates were made to ensure data is set immediately on text and textarea filter changes.
Focus Management Improvements:
FocusProvider
anduseFocusRestore
context infocus-context.tsx
to centralize and simplify focus restoration logic across filter components. ([assets/js/src/core/modules/element/listing/decorators/general-filters/view-layer/components/sidebar/tabs/filters/focus-context.tsxR1-R38](https://github.com/pimcore/studio-ui-bundle/pull/2143/files#diff-fa32b2bcb106ca1d9efa4cb4c77975b67e4914ac86354aebc8e71df990d6286fR1-R38)
)FilterContainerInner
withFocusProvider
, and added logic to restore focus to the sidebar container when appropriate (e.g., after applying filters or pressing Enter). ([[1]](https://github.com/pimcore/studio-ui-bundle/pull/2143/files#diff-2b881fc01f1312a9b40f0f9b5b0af369cd38df35996342404807d70b36410052R39-R43)
,[[2]](https://github.com/pimcore/studio-ui-bundle/pull/2143/files#diff-2b881fc01f1312a9b40f0f9b5b0af369cd38df35996342404807d70b36410052R88-R98)
,[[3]](https://github.com/pimcore/studio-ui-bundle/pull/2143/files#diff-2b881fc01f1312a9b40f0f9b5b0af369cd38df35996342404807d70b36410052R119-R127)
,[[4]](https://github.com/pimcore/studio-ui-bundle/pull/2143/files#diff-2b881fc01f1312a9b40f0f9b5b0af369cd38df35996342404807d70b36410052R187-R189)
)FieldFiltersContainer
to restore focus when the number of filters increases, improving keyboard navigation and accessibility. ([[1]](https://github.com/pimcore/studio-ui-bundle/pull/2143/files#diff-2dd1ca3104fec4ab0724f56c12d8db6f270231a8c0f2c36eff5acbe8adffb2daR23)
,[[2]](https://github.com/pimcore/studio-ui-bundle/pull/2143/files#diff-2dd1ca3104fec4ab0724f56c12d8db6f270231a8c0f2c36eff5acbe8adffb2daR32)
,[[3]](https://github.com/pimcore/studio-ui-bundle/pull/2143/files#diff-2dd1ca3104fec4ab0724f56c12d8db6f270231a8c0f2c36eff5acbe8adffb2daR51)
,[[4]](https://github.com/pimcore/studio-ui-bundle/pull/2143/files#diff-2dd1ca3104fec4ab0724f56c12d8db6f270231a8c0f2c36eff5acbe8adffb2daR68-R74)
)Component Refactoring for Focus Restoration:
useFocusRestore
, restoring sidebar focus when dropdowns close. ([[1]](https://github.com/pimcore/studio-ui-bundle/pull/2143/files#diff-dcbabd445dfdfc3ae638ed81dd12dc3c70dc1f4ec60a8c6c47c9e5eb23b36de5R15)
,[[2]](https://github.com/pimcore/studio-ui-bundle/pull/2143/files#diff-dcbabd445dfdfc3ae638ed81dd12dc3c70dc1f4ec60a8c6c47c9e5eb23b36de5R45)
,[[3]](https://github.com/pimcore/studio-ui-bundle/pull/2143/files#diff-dcbabd445dfdfc3ae638ed81dd12dc3c70dc1f4ec60a8c6c47c9e5eb23b36de5R80)
,[[4]](https://github.com/pimcore/studio-ui-bundle/pull/2143/files#diff-86cb4acb9f4d7262f78cb9387a9cbe1b9aa4dcdf086aa023131088e183ef9736R20)
,[[5]](https://github.com/pimcore/studio-ui-bundle/pull/2143/files#diff-86cb4acb9f4d7262f78cb9387a9cbe1b9aa4dcdf086aa023131088e183ef9736R42)
,[[6]](https://github.com/pimcore/studio-ui-bundle/pull/2143/files#diff-86cb4acb9f4d7262f78cb9387a9cbe1b9aa4dcdf086aa023131088e183ef9736R110-R112)
,[[7]](https://github.com/pimcore/studio-ui-bundle/pull/2143/files#diff-86cb4acb9f4d7262f78cb9387a9cbe1b9aa4dcdf086aa023131088e183ef9736R156)
,[[8]](https://github.com/pimcore/studio-ui-bundle/pull/2143/files#diff-86cb4acb9f4d7262f78cb9387a9cbe1b9aa4dcdf086aa023131088e183ef9736R177)
,[[9]](https://github.com/pimcore/studio-ui-bundle/pull/2143/files#diff-108afc58132b0e7861ea4732f261f17ee5ed67dbdef7c2c70d68c363672625d1R15)
,[[10]](https://github.com/pimcore/studio-ui-bundle/pull/2143/files#diff-108afc58132b0e7861ea4732f261f17ee5ed67dbdef7c2c70d68c363672625d1R29)
,[[11]](https://github.com/pimcore/studio-ui-bundle/pull/2143/files#diff-108afc58132b0e7861ea4732f261f17ee5ed67dbdef7c2c70d68c363672625d1R60)
)Immediate Data Setting in Text Filters:
[[1]](https://github.com/pimcore/studio-ui-bundle/pull/2143/files#diff-9ad6a7730b5da23e4e67d4c4d1dfa7fc0539ae6f7f5b1d7038e2643acc83ed8bL32-L40)
,[[2]](https://github.com/pimcore/studio-ui-bundle/pull/2143/files#diff-fc7b1866153cd9327cf6cf65c3ceac387aa924c5a6e1cd760b6e1dea301cc06dL28-L37)
)These changes collectively improve the accessibility and usability of the filter sidebar, especially for keyboard users and those relying on assistive technologies.