Skip to content

fix(AnalyticalTable): trap focus inside column header popover while open #5827

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

Merged
merged 1 commit into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -157,17 +157,9 @@ export const ColumnHeaderModal = (props: ColumnHeaderModalProperties) => {

useEffect(() => {
if (open && ref.current && openerRef.current) {
customElements
.whenDefined(getUi5TagWithSuffix('ui5-popover'))
.then(() => {
ref.current.opener = openerRef.current;
if (canRenderPortal && open) {
ref.current.showAt(openerRef.current);
}
})
.catch(() => {
// silently catch
});
void customElements.whenDefined(getUi5TagWithSuffix('ui5-popover')).then(() => {
ref.current.opener = openerRef.current;
});
}
}, [open, canRenderPortal]);

Expand All @@ -177,6 +169,7 @@ export const ColumnHeaderModal = (props: ColumnHeaderModalProperties) => {

return createPortal(
<Popover
open={open}
hideArrow
horizontalAlign={horizontalAlign}
placementType={PopoverPlacementType.Bottom}
Expand All @@ -185,8 +178,14 @@ export const ColumnHeaderModal = (props: ColumnHeaderModalProperties) => {
onClick={stopPropagation}
onAfterClose={onAfterClose}
onAfterOpen={onAfterOpen}
data-component-name="ATHeaderPopover"
>
<List onItemClick={handleSort} ref={listRef} onKeyDown={handleListKeyDown}>
<List
onItemClick={handleSort}
ref={listRef}
onKeyDown={handleListKeyDown}
data-component-name="ATHeaderPopoverList"
>
{isSortedAscending && (
<StandardListItem type={ListItemType.Active} icon={iconDecline} data-sort="clear">
{clearSortingText}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,14 @@ const useGetTableProps = (tableProps, { instance: { webComponentsReactProperties

const onTableFocus = useCallback(
(e) => {
if (e.target.dataset?.emptyRowCell === 'true' || e.target.dataset.subcomponentActiveElement) {
const { dataset } = e.target;
if (
dataset.emptyRowCell === 'true' ||
dataset.subcomponentActiveElement ||
// todo: with the new popover API of ui5wc this might not be necessary anymore
dataset.componentName === 'ATHeaderPopoverList' ||
dataset.componentName === 'ATHeaderPopover'
) {
return;
}
if (e.target.dataset.subcomponent) {
Expand Down
Loading