Skip to content

Commit f984d76

Browse files
committed
feat(react-provider): use feature flag
1 parent f0c77eb commit f984d76

4 files changed

Lines changed: 10 additions & 34 deletions

File tree

packages/react-components/react-button/library/etc/react-button.api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export type ButtonSlots = {
4747
// @public (undocumented)
4848
export type ButtonState = ComponentState<ButtonSlots> & Required<Pick<ButtonProps, 'appearance' | 'disabledFocusable' | 'disabled' | 'iconPosition' | 'shape' | 'size'>> & {
4949
iconOnly: boolean;
50+
isHovered: boolean;
5051
};
5152

5253
// @public

packages/react-components/react-button/library/src/components/Button/useButtonBase.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import * as React from 'react';
44
import { ARIAButtonSlotProps, useARIAButtonProps } from '@fluentui/react-aria';
55
import { getIntrinsicElementProps, slot, useHover_unstable } from '@fluentui/react-utilities';
6-
import { usePointerInteractions_unstable } from '@fluentui/react-shared-contexts';
6+
import { useOverrides_unstable as useOverrides } from '@fluentui/react-shared-contexts';
77
import type { ButtonBaseProps, ButtonBaseState } from './Button.types';
88

99
/**
@@ -18,19 +18,20 @@ export const useButtonBase_unstable = (
1818
const { as = 'button', disabled = false, disabledFocusable = false, icon, iconPosition = 'before' } = props;
1919
const iconShorthand = slot.optional(icon, { elementType: 'span' });
2020

21-
// Check if pointer-aware hover behavior is enabled via FluentProvider
22-
const { usePointerHover } = usePointerInteractions_unstable();
21+
// Check if smart hover behavior is enabled via FluentProvider
22+
const overrides = useOverrides();
23+
const smartHover = overrides.smartHover ?? false;
2324

24-
// Use pointer-aware hover hook - disabled when feature flag is off or button is disabled
25+
// Use smart hover hook - disabled when feature flag is off or button is disabled
2526
const { hoverProps, isHovered } = useHover_unstable({
26-
isDisabled: !usePointerHover || disabled || disabledFocusable,
27+
isDisabled: !smartHover || disabled || disabledFocusable,
2728
});
2829

2930
// Get base ARIA button props
3031
const ariaButtonProps = useARIAButtonProps(props.as, props);
3132

32-
// Merge hover props with ARIA button props when pointer hover is enabled
33-
const mergedProps = usePointerHover
33+
// Merge hover props with ARIA button props when smart hover is enabled
34+
const mergedProps = smartHover
3435
? {
3536
...ariaButtonProps,
3637
...hoverProps,

packages/react-components/react-shared-contexts/library/src/OverridesContext/OverridesContext.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import * as React from 'react';
88
export type OverridesContextValue = {
99
// No 'underline' as it is not supported by TextArea
1010
inputDefaultAppearance?: 'outline' | 'filled-darker' | 'filled-lighter';
11+
smartHover?: boolean;
1112
};
1213

1314
/**

packages/react-components/react-utilities/etc/react-utilities.api.md

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -119,27 +119,6 @@ export function getTriggerChild<TriggerChildProps>(children: TriggerProps<Trigge
119119
ref?: React_2.Ref<any>;
120120
}) | null;
121121

122-
// @public
123-
export interface HoverEvent {
124-
pointerType: PointerType;
125-
target: HTMLElement;
126-
type: 'hoverstart' | 'hoverend';
127-
}
128-
129-
// @public
130-
export interface HoverProps {
131-
isDisabled?: boolean;
132-
onHoverChange?: (isHovered: boolean) => void;
133-
onHoverEnd?: (e: HoverEvent) => void;
134-
onHoverStart?: (e: HoverEvent) => void;
135-
}
136-
137-
// @public
138-
export interface HoverResult {
139-
hoverProps: React_2.DOMAttributes<HTMLElement>;
140-
isHovered: boolean;
141-
}
142-
143122
// @public
144123
export const IdPrefixProvider: React_2.Provider<string | undefined>;
145124

@@ -200,9 +179,6 @@ function optional<Props extends UnknownSlotProps>(value: Props | SlotShorthandVa
200179
renderByDefault?: boolean;
201180
} & SlotOptions<Props>): SlotComponentType<Props> | undefined;
202181

203-
// @public
204-
export type PointerType = 'mouse' | 'pen';
205-
206182
// @internal (undocumented)
207183
export interface PriorityQueue<T> {
208184
// (undocumented)
@@ -400,9 +376,6 @@ export function useFirstMount(): boolean;
400376
// @internal
401377
export function useForceUpdate(): React_2.DispatchWithoutAction;
402378

403-
// @public
404-
export function useHover_unstable(props: HoverProps): HoverResult;
405-
406379
// @public
407380
export function useId(prefix?: string, providedId?: string): string;
408381

0 commit comments

Comments
 (0)