Skip to content
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
Copy link
Copy Markdown

@github-actions github-actions Bot Jun 2, 2026

Choose a reason for hiding this comment

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

🕵🏾‍♀️ visual changes to review in the Visual Change Report

vr-tests-web-components/Badge 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-web-components/Badge. - Dark Mode.normal.chromium.png 443 Changed
vr-tests-web-components/MenuList 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-web-components/MenuList. - RTL.1st selected.chromium_2.png 38479 Changed

"type": "prerelease",
"comment": "avoid dialog from focusing on non-active tab upon showing",
"packageName": "@fluentui/web-components",
"email": "machi@microsoft.com",
"dependentChangeType": "patch"
}
41 changes: 41 additions & 0 deletions packages/web-components/src/dialog/dialog.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { Locator } from '@playwright/test';
import { expect, test } from '../../test/playwright/index.js';
import { tagName as DialogBodyTagName } from '../dialog-body/dialog-body.options.js';
import { tagName as TabTagName } from '../tab/tab.options.js';
import { tagName as TablistTagName } from '../tablist/tablist.options.js';
import type { Dialog } from './dialog.js';
import { tagName } from './dialog.options.js';

Expand Down Expand Up @@ -383,4 +385,43 @@ test.describe('Dialog', () => {

await expect(content).toBeHidden();
});

test.describe('opening focus', () => {
test.use({
tagName,
waitFor: [DialogBodyTagName, TablistTagName, TabTagName],
});

test('should not change tablist’s `activeid` attribute', async ({ fastPage }) => {
const { element } = fastPage;
const content = element.locator('#content');
const tablist = element.locator(TablistTagName);

await fastPage.setTemplate({
innerHTML: /* html */ `
<${DialogBodyTagName} id="content">
<${TablistTagName} activeid="tab2">
<${TabTagName} id="tab1">tab 1</${TabTagName}>
<${TabTagName} id="tab2">tab 2</${TabTagName}>
</${TablistTagName}>
</${DialogBodyTagName}>
`,
});

await element.evaluate((node: Dialog) => {
node.show();
});

await expect(content).toBeVisible();
await expect(tablist).toHaveAttribute('activeid', 'tab2');

await element.evaluate((node: Dialog) => {
node.hide();
node.show();
});

await expect(content).toBeVisible();
await expect(tablist).toHaveAttribute('activeid', 'tab2');
});
});
});
15 changes: 15 additions & 0 deletions packages/web-components/src/dialog/dialog.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,3 +399,18 @@ export const ScrollingLongContent: Story = {
},
],
};

export const WithTablist: Story = {
args: {
ariaLabel: 'With Tablist',
titleSlottedContent: () => html` <h2 slot="title">With Tablist</h2> `,
closeSlottedContent: () => html``,
slottedContent: () => html`
<fluent-tablist activeid="tab2">
<fluent-tab id="tab1">tab 1</fluent-tab>
<fluent-tab id="tab2">tab 2</fluent-tab>
<fluent-tab id="tab3">tab 3</fluent-tab>
</fluent-tablist>
`,
},
};
6 changes: 6 additions & 0 deletions packages/web-components/src/dialog/dialog.template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ import type { Dialog } from './dialog.js';

/**
* Template for the Dialog component
*
* Note: The empty `<div tabindex="-1">` element above the `<slot>` element is
* for working around a dialog focus issue, learn more at
* https://github.com/microsoft/fluentui/pull/36278
*
* @public
*/
export const template: ElementViewTemplate<Dialog> = html`
Expand All @@ -18,6 +23,7 @@ export const template: ElementViewTemplate<Dialog> = html`
@cancel="${x => x.hide()}"
${ref('dialog')}
>
<div tabindex="-1"></div>
<slot></slot>
</dialog>
`;
Loading