Skip to content
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
7 changes: 7 additions & 0 deletions .changeset/strict-points-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@fluentui-react-native/components": patch
"@fluentui-react-native/desktop-driver": patch
"@fluentui-react-native/framework-base": patch
---

Fix native Divider separator semantics, button and popup-trigger accessibility activation, Win32 keyboard press lifecycle and grouped Tab navigation, and standalone ListboxItem accessible names exposed by expanded agentic component tests. macOS Fabric press activation requires the repository's React Native macOS patch.
31 changes: 30 additions & 1 deletion .yarn/patches/react-native-macos-npm-0.81.9-aa583a0648.patch
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ index e7254907271b70783e886d378c7824df46e04e93..fbe1d5d7e834afb4553adb03253e34f6
if (newTextInputProps.multiline &&
newTextInputProps.traits.dataDetectorTypes != oldTextInputProps.traits.dataDetectorTypes) {
diff --git a/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm
index 6e20d03f64385e3729a7517c6fb8b31f6177d52d..6710864c9e9252556f7fad00caf1bbea2e80192b 100644
index 6e20d03f64385e3729a7517c6fb8b31f6177d52d..c45606ad4215a21ff7312c1fc35ac27dd56dd51e 100644
--- a/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm
+++ b/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm
@@ -35,6 +35,7 @@
Expand Down Expand Up @@ -162,3 +162,32 @@ index 6e20d03f64385e3729a7517c6fb8b31f6177d52d..6710864c9e9252556f7fad00caf1bbea
#if !TARGET_OS_OSX // [macOS]
// `accessibilityState`
if (oldViewProps.accessibilityState != newViewProps.accessibilityState) {
@@ -1661,8 +1687,28 @@ static NSString *RCTRecursiveAccessibilityLabel(RCTUIView *view) // [macOS]
return [customActions copy];
}

+#if TARGET_OS_OSX // [macOS
+- (BOOL)isAccessibilitySelectorAllowed:(SEL)selector
+{
+ if (selector == @selector(accessibilityPerformPress)) {
+ return _props && _eventEmitter && _props->onAccessibilityTap &&
+ [self.accessibilityElement isAccessibilityEnabled];
+ }
+ return [super isAccessibilitySelectorAllowed:selector];
+}
+#endif // macOS]
+
+#if !TARGET_OS_OSX // [macOS]
- (BOOL)accessibilityActivate
+#else // [macOS
+- (BOOL)accessibilityPerformPress
+#endif // macOS]
{
+#if TARGET_OS_OSX // [macOS
+ if (![self isAccessibilitySelectorAllowed:_cmd]) {
+ return NO;
+ }
+#endif // macOS]
if (_eventEmitter && _props->onAccessibilityTap) {
_eventEmitter->onAccessibilityTap();
return YES;
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ import type { ReactNode } from 'react';
import { StyleSheet, Text, View } from 'react-native';

import type { Meta, StoryObj } from '@storybook/react-native';
import { desktopIt } from '@fluentui-react-native/storybook-desktop/testing';
import type { WdioStory } from '@fluentui-react-native/storybook-desktop/testing';

import { Accordion } from './accordion';
import type { AccordionLayout } from './accordion.types';
import { Input } from '../input/input';
import { Button } from '../button/button';
import { StoryStatus } from '../../common/StoryStatus.story-helpers';

type StoryGroupProps = {
children: ReactNode;
Expand Down Expand Up @@ -49,7 +54,88 @@ const meta: Meta<typeof Accordion> = {

export default meta;

type Story = StoryObj<typeof Accordion>;
type Story = WdioStory<StoryObj<typeof Accordion>>;

function KeyboardDisclosureScene() {
const [changes, setChanges] = useState(0);
return (
<View>
<Input accessibilityLabel="Disclosure entry" testID="accordion-keyboard-entry" />
<Accordion
accessibilityLabel="Supporting details"
title="Supporting details"
onExpandedChange={() => setChanges((count) => count + 1)}
bodyContent={{ children: <Button content="Body action" testID="accordion-keyboard-body-action" /> }}
/>
<Button content="After disclosure" testID="accordion-keyboard-after" />
<StoryStatus testID="accordion-keyboard-count">{String(changes)}</StoryStatus>
</View>
);
}

export const KeyboardDisclosure: Story = {
render: () => <KeyboardDisclosureScene />,
tags: ['desktop-focus'],
parameters: {
docs: {
description: {
story: 'Activation retains header focus; an explicit Tab enters the expanded body and Shift+Tab returns to the header.',
},
},
},
wdio: [
desktopIt(
'ACC-001 ACC-004 expands and collapses once per keyboard activation without transferring header focus',
{ requires: ['physical-click', 'keyboard', 'focus'] },
async ({ browser, expect }) => {
const { expectNativeState, focusByTab } = await import('../../common/desktopFocus.wdio.ts');
const header = await browser.$('~accordion-header');
await focusByTab(browser, 'accordion-keyboard-entry', 'accordion-header');
expect(await header.getTagName()).toBe('button');
expect(await header.getProperty('name')).toBe('Supporting details');
expect(await header.getProperty('expanded')).toBe(false);
await browser.keys('\uE00D');
await expect(await browser.$('~accordion-keyboard-count')).toHaveText('1');
expect(await header.getProperty('expanded')).toBe(true);
await expectNativeState(browser, 'accordion-header', 'focused', true);
await browser.keys('\uE004');
await expectNativeState(browser, 'accordion-keyboard-body-action', 'focused', true);
await browser.keys(['\uE008', '\uE004']);
await expectNativeState(browser, 'accordion-header', 'focused', true);
await browser.keys('\uE00D');
await expect(await browser.$('~accordion-keyboard-count')).toHaveText('2');
expect(await header.getProperty('expanded')).toBe(false);
await expectNativeState(browser, 'accordion-header', 'focused', true);
},
),
desktopIt(
'ACC-001 suppresses repeated Space keydown and preserves native activation phase',
{ requires: ['physical-click', 'keyboard', 'focus'] },
async ({ browser, expect, platform }) => {
const { focusByTab } = await import('../../common/desktopFocus.wdio.ts');
await focusByTab(browser, 'accordion-keyboard-entry', 'accordion-header');
try {
await browser.performActions([
{
type: 'key',
id: 'accordion-keyboard',
actions: [
{ type: 'keyDown', value: '\uE00D' },
{ type: 'keyDown', value: '\uE00D' },
],
},
]);
await expect(await browser.$('~accordion-keyboard-count')).toHaveText(platform === 'macos' ? '1' : '0');
await browser.performActions([{ type: 'key', id: 'accordion-keyboard', actions: [{ type: 'keyUp', value: '\uE00D' }] }]);
await expect(await browser.$('~accordion-keyboard-count')).toHaveText('1');
expect(await (await browser.$('~accordion-header')).getProperty('expanded')).toBe(true);
} finally {
await browser.releaseActions();
}
},
),
],
};

export const Default: Story = {
parameters: {
Expand Down Expand Up @@ -136,7 +222,7 @@ export const ExternallyDrivenExpansion: Story = {
<Accordion
key={name}
expanded={open === name}
onExpandedChange={(expanded) => setOpen(expanded ? name : null)}
onExpandedChange={(expanded: boolean) => setOpen(expanded ? name : null)}
title={{ children: name }}
/>
))}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/** @jsxImportSource @fluentui-react-native/framework-base */
import { StyleSheet } from 'react-native';
import * as React from 'react';
import { StyleSheet, type View } from 'react-native';
import type { ViewStyle } from 'react-native';

import { render } from '../../common/renderWithTheme';
import { fireEvent } from '@testing-library/react-native';
import type { RenderResult } from '@testing-library/react-native';

import { defaultFlexTokens } from '@fluentui-react-native/design/testing';
Expand All @@ -18,6 +20,20 @@ function getRootStyle(component: RenderResult): ViewStyle {
}

describe('Avatar', () => {
it('AVT-005 forwards the native root ref and layout event without making the identity focusable', async () => {
const ref = React.createRef<React.ComponentRef<typeof View>>();
const onLayout = jest.fn();
const component = await renderAvatar({ ref, onLayout, accessibilityLabel: 'Identity', testID: 'avatar' });
const event = { nativeEvent: { layout: { x: 0, y: 0, width: 40, height: 40 } } };
expect(ref.current).not.toBeNull();
await fireEvent(component.getByTestId('avatar'), 'layout', event);
expect(onLayout).toHaveBeenCalledTimes(1);
expect(onLayout).toHaveBeenCalledWith(event);
expect(component.getByTestId('avatar').props.focusable).not.toBe(true);
await component.unmount();
expect(ref.current).toBeNull();
});

it.each([
[16, ' lmn ', 'L'],
[40, ' lmn ', 'LM'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import type { ReactNode } from 'react';
import { StyleSheet, Text, View } from 'react-native';

import type { Meta, StoryObj } from '@storybook/react-native';
import { desktopIt } from '@fluentui-react-native/storybook-desktop/testing';
import type { WdioStory } from '@fluentui-react-native/storybook-desktop/testing';

import { Badge } from './badge';
import type { BadgeAppearance, BadgeColor, BadgeLayout, BadgeShape, BadgeSize } from './badge.types';
Expand Down Expand Up @@ -88,7 +90,26 @@ const meta: Meta<typeof Badge> = {

export default meta;

type Story = StoryObj<typeof Badge>;
type Story = WdioStory<StoryObj<typeof Badge>>;

export const NativeSemantics: Story = {
render: () => (
<Badge
testID="badge-native-status"
accessibilityLabel="Three unread notifications"
content="3"
leadingIcon={{ fontSource: { codepoint: 0x2022, fontFamily: 'Arial' } }}
/>
),
wdio: [
desktopIt('BDG-005 exposes one named native image for an informative status', async ({ browser, expect }) => {
const badge = await browser.$('~badge-native-status');
await expect(badge).toExist();
expect(await badge.getTagName()).toBe('image');
expect(await badge.getProperty('name')).toBe('Three unread notifications');
}),
],
};

export const Default: Story = {};

Expand Down
20 changes: 19 additions & 1 deletion packages/agentic/components/src/components/badge/badge.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/** @jsxImportSource @fluentui-react-native/framework-base */
import { StyleSheet } from 'react-native';
import * as React from 'react';
import { StyleSheet, type View } from 'react-native';
import type { ViewStyle } from 'react-native';

import { render } from '../../common/renderWithTheme';
Expand All @@ -24,6 +25,23 @@ function getRootStyle(component: Awaited<ReturnType<typeof renderBadge>>): ViewS
}

describe('Badge', () => {
it('BDG-002 forwards the root ref and permits a deliberately empty badge without restoring default content', async () => {
const ref = React.createRef<React.ComponentRef<typeof View>>();
const component = await renderBadge({
accessibilityLabel: 'Status',
content: null,
leadingIconVisible: false,
ref,
testID: 'empty-badge',
});
expect(ref.current).not.toBeNull();
expect(component.getByTestId('empty-badge').children).toHaveLength(0);
expect(component.queryByText('Badge')).toBeNull();
expect(getRoot(component).props).toMatchObject({ accessibilityLabel: 'Status', focusable: false });
await component.unmount();
expect(ref.current).toBeNull();
});

it('BDG-002/BDG-004 hides an unnamed default badge and renders no unsupplied trailing icon', async () => {
const component = await renderBadge({ testID: 'badge', trailingIconVisible: true });

Expand Down
59 changes: 57 additions & 2 deletions packages/agentic/components/src/components/card/card.test.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/** @jsxImportSource @fluentui-react-native/framework-base */
import * as React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { Dimensions, StyleSheet, Text, View } from 'react-native';
import type { ViewStyle } from 'react-native';

import { fireEvent } from '@testing-library/react-native';
import { act, fireEvent } from '@testing-library/react-native';
import { render } from '../../common/renderWithTheme';
import type { RenderResult } from '@testing-library/react-native';

Expand All @@ -25,6 +25,61 @@ function getRootStyle(component: RenderResult): ViewStyle {
}

describe('Card', () => {
it.each([
[479, 'column'],
[480, 'row'],
[1000, 'row'],
] as const)(
'CRD-001 resolves horizontal flow at viewport width %s independently of a narrow caller width',
async (width, flexDirection) => {
const previousWindow = Dimensions.get('window');
const previousScreen = Dimensions.get('screen');
await act(async () => Dimensions.set({ window: { ...previousWindow, width }, screen: previousScreen }));
try {
const component = await renderCard({ direction: 'horizontal', style: { width: 120 }, testID: 'card-root' });
expect(getRootStyle(component)).toMatchObject({ flexDirection, width: 120, maxWidth: 720, minWidth: 0, flexShrink: 1 });
await component.rerender(<Card direction="vertical" style={{ width: 120 }} testID="card-root" />);
expect(getRootStyle(component).flexDirection).toBe('column');
} finally {
await act(async () => Dimensions.set({ window: previousWindow, screen: previousScreen }));
}
},
);

it.each([
['small', 'default', 'base600', 'base300'],
['small', 'none', 'base600', 'base600'],
['large', 'default', 'base700', 'base400'],
['large', 'none', 'base700', 'base700'],
] as const)(
'CRD-003 resolves %s size and %s padding for the shell and additional nested block',
async (size, padding, shellRadius, nestedRadius) => {
const component = await renderCard({
size,
padding,
layout: 'nested',
testID: 'card-root',
content: { testID: 'content' },
content02: { testID: 'content02' },
});
expect(getRootStyle(component)).toMatchObject({
borderRadius: defaultFlexTokens.borderRadius[shellRadius],
padding: padding === 'none' ? 0 : defaultFlexTokens.spacing.componentBase300,
borderWidth: defaultFlexTokens.strokeWidth.thin,
});
const primary = StyleSheet.flatten(component.getByTestId('content').props.style);
expect(primary).toMatchObject({ flexShrink: 1, minWidth: 0, alignSelf: 'stretch' });
expect(primary.borderRadius).toBeUndefined();
expect(primary.overflow).toBeUndefined();
expect(StyleSheet.flatten(component.getByTestId('content02').props.style)).toMatchObject({
borderRadius: defaultFlexTokens.borderRadius[nestedRadius],
backgroundColor: defaultFlexTokens.color.backgroundNeutralTranslucent.rest,
flexShrink: 1,
overflow: 'hidden',
});
},
);

it.each([
[undefined, false],
[false, true],
Expand Down
Loading
Loading