Skip to content
Draft
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
@@ -0,0 +1,7 @@
{
Copy link

@github-actions github-actions bot Mar 5, 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-react-components/CalendarCompat 4 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/CalendarCompat.multiDayView.default.chromium.png 495 Changed
vr-tests-react-components/CalendarCompat.multiDayView.default.chromium_1.png 403 Changed
vr-tests-react-components/CalendarCompat.multiDayView - Dark Mode.default.chromium.png 1107 Changed
vr-tests-react-components/CalendarCompat.multiDayView - High Contrast.default.chromium.png 1236 Changed
vr-tests-react-components/Charts-DonutChart 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Charts-DonutChart.Dynamic - RTL.default.chromium.png 5570 Changed
vr-tests-react-components/Menu Converged - submenuIndicator slotted content 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Menu Converged - submenuIndicator slotted content.default - RTL.submenus open.chromium.png 404 Changed
vr-tests-react-components/Menu Converged - submenuIndicator slotted content.default.submenus open.chromium.png 413 Changed
vr-tests-react-components/Positioning 2 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/Positioning.Positioning end.chromium.png 609 Changed
vr-tests-react-components/Positioning.Positioning end.updated 2 times.chromium.png 497 Changed
vr-tests-react-components/TagPicker 3 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests-react-components/TagPicker.disabled - Dark Mode.disabled input hover.chromium.png 658 Changed
vr-tests-react-components/TagPicker.disabled - High Contrast.chromium.png 1319 Changed
vr-tests-react-components/TagPicker.disabled.disabled input hover.chromium.png 677 Changed

There were 4 duplicate changes discarded. Check the build logs for more information.

"type": "minor",
"comment": "feat: add base hooks for SearchBox",
"packageName": "@fluentui/react-search",
"email": "dmytrokirpa@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
export type {
SearchBoxChangeEvent,
SearchBoxProps,
SearchBoxBaseProps,
SearchBoxSlots,
SearchBoxState,
SearchBoxBaseState,
} from './components/SearchBox/index';
export {
SearchBox,
renderSearchBox_unstable,
searchBoxClassNames,
useSearchBoxStyles_unstable,
useSearchBox_unstable,
useSearchBoxBase_unstable,
} from './components/SearchBox/index';
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';
import type { ComponentProps, ComponentState, DistributiveOmit, Slot } from '@fluentui/react-utilities';
import type { InputOnChangeData, InputProps, InputSlots, InputState } from '@fluentui/react-input';

export type SearchBoxSlots = InputSlots & {
Expand All @@ -26,6 +26,11 @@ export type SearchBoxProps = Omit<
onChange?: (event: SearchBoxChangeEvent, data: InputOnChangeData) => void;
};

/**
* SearchBox base props — excludes design props (appearance, size).
*/
export type SearchBoxBaseProps = DistributiveOmit<SearchBoxProps, 'appearance' | 'size'>;

/**
* State used in rendering SearchBox
*/
Expand All @@ -36,5 +41,10 @@ export type SearchBoxState = ComponentState<SearchBoxSlots> &
focused: boolean;
};

/**
* SearchBox base state — excludes design props (appearance, size).
*/
export type SearchBoxBaseState = DistributiveOmit<SearchBoxState, 'appearance' | 'size'>;

/** Overloaded onChange event type, used to merge functionality of regular text entry and the dismiss button */
export type SearchBoxChangeEvent = React.ChangeEvent<HTMLInputElement> | React.MouseEvent<HTMLSpanElement>;
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
export { SearchBox } from './SearchBox';
export type { SearchBoxChangeEvent, SearchBoxProps, SearchBoxSlots, SearchBoxState } from './SearchBox.types';
export type {
SearchBoxChangeEvent,
SearchBoxProps,
SearchBoxBaseProps,
SearchBoxSlots,
SearchBoxState,
SearchBoxBaseState,
} from './SearchBox.types';
export { renderSearchBox_unstable } from './renderSearchBox';
export { useSearchBox_unstable } from './useSearchBox';
export { useSearchBox_unstable, useSearchBoxBase_unstable } from './useSearchBox';
export { searchBoxClassNames, useSearchBoxStyles_unstable } from './useSearchBoxStyles.styles';
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ import {
import { useInput_unstable } from '@fluentui/react-input';
import { DismissRegular, SearchRegular } from '@fluentui/react-icons';
import type { ExtractSlotProps } from '@fluentui/react-utilities';
import type { SearchBoxSlots, SearchBoxProps, SearchBoxState } from './SearchBox.types';
import type {
SearchBoxBaseProps,
SearchBoxBaseState,
SearchBoxSlots,
SearchBoxProps,
SearchBoxState,
} from './SearchBox.types';

/**
* Create the state required to render SearchBox.
Expand All @@ -24,17 +30,29 @@ import type { SearchBoxSlots, SearchBoxProps, SearchBoxState } from './SearchBox
* @param ref - reference to root HTMLElement of SearchBox
*/
export const useSearchBox_unstable = (props: SearchBoxProps, ref: React.Ref<HTMLInputElement>): SearchBoxState => {
const {
size = 'medium',
disabled = false,
root,
contentBefore,
dismiss,
contentAfter,
value,
defaultValue,
...inputProps
} = props;
const { size = 'medium', appearance = 'outline', ...baseProps } = props;
const state = useSearchBoxBase_unstable(baseProps, ref);

return {
...state,
size,
appearance,
};
};

/**
* Base hook for SearchBox component. Manages state related to controlled/uncontrolled
* value, focus tracking, dismiss button click handling, search icon slot, and
* input type="search" — without design props (size, appearance).
*
* @param props - props from this instance of SearchBox (without size, appearance)
* @param ref - reference to root HTMLElement of SearchBox
*/
export const useSearchBoxBase_unstable = (
props: SearchBoxBaseProps,
ref: React.Ref<HTMLInputElement>,
): SearchBoxBaseState => {
const { disabled = false, root, contentBefore, dismiss, contentAfter, value, defaultValue, ...inputProps } = props;

const searchBoxRootRef = React.useRef<HTMLDivElement>(null);
const searchBoxRef = React.useRef<HTMLInputElement>(null);
Expand Down Expand Up @@ -76,7 +94,6 @@ export const useSearchBox_unstable = (props: SearchBoxProps, ref: React.Ref<HTML
{
type: 'search',
disabled,
size,
value: internalValue,
root: slot.always<ExtractSlotProps<SearchBoxSlots['root']>>(
{
Expand Down Expand Up @@ -110,7 +127,7 @@ export const useSearchBox_unstable = (props: SearchBoxProps, ref: React.Ref<HTML
useMergedRefs(searchBoxRef, ref),
);

const state: SearchBoxState = {
const state: SearchBoxBaseState = {
...inputState,
components: {
// eslint-disable-next-line @typescript-eslint/no-deprecated
Expand All @@ -129,7 +146,6 @@ export const useSearchBox_unstable = (props: SearchBoxProps, ref: React.Ref<HTML
}),
disabled,
focused,
size,
};

if (state.dismiss) {
Expand Down
4 changes: 4 additions & 0 deletions packages/react-components/react-search/library/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ export {
useSearchBox_unstable,
} from './SearchBox';
export type { SearchBoxChangeEvent, SearchBoxProps, SearchBoxSlots, SearchBoxState } from './SearchBox';

// Experimental APIs - will be uncommented in the experimental release branch
// export { useSearchBoxBase_unstable } from './SearchBox';
// export type { SearchBoxBaseProps, SearchBoxBaseState } from './SearchBox';