Skip to content
Open
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
6 changes: 5 additions & 1 deletion packages/main/src/components/ActionSheet/ActionSheet.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import * as ComponentStories from './ActionSheet.stories';

<Meta of={ComponentStories} />

<DocsHeader of={ComponentStories} subComponents={['Button']} />
<DocsHeader
of={ComponentStories}
subComponents={['Button']}
deprecationText="This component has a number of limitations. Use a `Menu` instead of the `ActionSheet` whenever possible."
/>

<br />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ const meta = {
parameters: {
chromatic: { disableSnapshot: true },
},
tags: ['extends:@ui5/webcomponents', 'cem-module:ResponsivePopover', 'package:@ui5/webcomponents-react'],
tags: [
'extends:@ui5/webcomponents',
'cem-module:ResponsivePopover',
'package:@ui5/webcomponents-react',
'deprecated',
],
} satisfies Meta<typeof ActionSheet>;

export default meta;
Expand Down
5 changes: 5 additions & 0 deletions packages/main/src/components/ActionSheet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ function ActionSheetButton(props: ActionSheetButtonPropTypes) {
* - Always provide a Cancel button on mobile phones.
* - Avoid scrolling on action sheets.
*
* @deprecated This component has a number of limitations. Use a `Menu` instead of the `ActionSheet` whenever possible.
*/
const ActionSheet = forwardRef<ResponsivePopoverDomRef, ActionSheetPropTypes>((props, ref) => {
const { accessibilityAttributes, children, className, header, headerText, hideCancelButton, onOpen, open, ...rest } =
Expand Down Expand Up @@ -204,6 +205,10 @@ const ActionSheet = forwardRef<ResponsivePopoverDomRef, ActionSheetPropTypes>((p
.querySelector(`[data-action-btn-index="${Math.min(currentIndex + 5, childrenLength - 1)}"]`)
.focus();
break;
case 'Tab':
// prevent focus from escaping popover
e.preventDefault();
break;
case 'Home':
e.preventDefault();
actionBtnsRef.current.querySelector(`[data-action-btn-index="0"]`).focus();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Button } from '../../../webComponents/Button/index.js';
import { ActionSheet } from '../index.js';

export const ActionSheetKeyboardTestComp = () => {
return (
<>
<button id="opener" data-testid="opener">
Opener
</button>
<ActionSheet open opener="opener">
{new Array(5).fill('').map((_, index) => (
<Button key={index}>{`Button${index}`}</Button>
))}
</ActionSheet>
</>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { expect, test } from '../../../../../../playwright/fixtures/gallery-fixtures.js';

test.describe('ActionSheet', () => {
test('Tab does not move focus or escape the popover', async ({ mount, page }) => {
await mount('ActionSheet/ActionSheetKeyboardTestComp');
await expect(page.locator('[ui5-responsive-popover]')).toBeVisible();

const btn = (index: number) => page.locator(`[data-action-btn-index="${index}"]`);

await expect(btn(0)).toBeFocused();

await page.keyboard.press('ArrowDown');
await expect(btn(1)).toBeFocused();

await page.keyboard.press('Tab');
await expect(btn(1)).toBeFocused();

await page.keyboard.press('Shift+Tab');
await expect(btn(1)).toBeFocused();
});
});
Loading