diff --git a/SearchBox/README.md b/SearchBox/README.md index 98e35d18..64952d4c 100644 --- a/SearchBox/README.md +++ b/SearchBox/README.md @@ -20,6 +20,8 @@ This code component provides a wrapper around the [Fluent UI SearchBox](https:// - **Delay Output** - To delay output by half a second. Useful when input is provided frequently within short duration. +- **Border color** - To define specific color for searchbox border. This exludes onhover & onfocus border color. + ## Additional properties - **Theme** - Accepts a JSON string that is generated using [Fluent UI Theme Designer (windows.net)](https://fabricweb.z5.web.core.windows.net/pr-deploy-site/refs/heads/master/theming-designer/). Leaving this blank will use the default theme defined by Power Apps. Leaving this blank will use the default theme defined by Power Apps. See [theming](theme.md) for guidance on how to configure. diff --git a/SearchBox/SearchBox/ControlManifest.Input.xml b/SearchBox/SearchBox/ControlManifest.Input.xml index 79eef71c..2c0be70e 100644 --- a/SearchBox/SearchBox/ControlManifest.Input.xml +++ b/SearchBox/SearchBox/ControlManifest.Input.xml @@ -1,7 +1,6 @@ - @@ -11,6 +10,7 @@ + diff --git a/SearchBox/SearchBox/__mocks__/mock-parameters.ts b/SearchBox/SearchBox/__mocks__/mock-parameters.ts index 2baedd8b..221317ff 100644 --- a/SearchBox/SearchBox/__mocks__/mock-parameters.ts +++ b/SearchBox/SearchBox/__mocks__/mock-parameters.ts @@ -14,5 +14,6 @@ export function getMockParameters(): IInputs { InputEvent: new MockStringProperty(), DelayOutput: new MockTwoOptionsProperty(), SearchText: new MockStringProperty(), + BorderColor: new MockStringProperty() }; } diff --git a/SearchBox/SearchBox/__tests__/__snapshots__/searchbox-lifecycle.test.ts.snap b/SearchBox/SearchBox/__tests__/__snapshots__/searchbox-lifecycle.test.ts.snap index 57d5b3b1..3aa88a38 100644 --- a/SearchBox/SearchBox/__tests__/__snapshots__/searchbox-lifecycle.test.ts.snap +++ b/SearchBox/SearchBox/__tests__/__snapshots__/searchbox-lifecycle.test.ts.snap @@ -3,6 +3,7 @@ exports[`SearchBox renders 1`] = ` { - const { onChange, themeJSON, ariaLabel, placeholderText, underLined, disabled, disableAnimation, setFocus, value } = - props; + const { + onChange, + themeJSON, + ariaLabel, + placeholderText, + underLined, + disabled, + disableAnimation, + setFocus, + value, + width, + borderColor, + } = props; const filterIcon: IIconProps = { iconName: props.iconName }; const [searchText, setSearchText] = React.useState(value); const rootRef = React.useRef(null); @@ -19,16 +30,19 @@ export const SearchBoxComponent = React.memo((props: ISearchBoxComponentProps) = React.useEffect(() => { value !== searchText && setSearchText(value); - }, [value, searchText]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [value]); function onChangeEvent(ev?: React.ChangeEvent, newValue?: string) { setSearchText(newValue); onChange(ev, newValue); } - const wrapperClass = mergeStyles({ - width: props.width, - }); + const searchboxStyles = React.useMemo(() => { + return { + root: { width: width, ...(borderColor && { borderColor: borderColor }) }, + } as ISearchBoxStyles; + }, [width, borderColor]); React.useEffect(() => { if (setFocus && setFocus !== '' && rootRef) { @@ -38,7 +52,6 @@ export const SearchBoxComponent = React.memo((props: ISearchBoxComponentProps) = } } }, [setFocus, rootRef]); - return ( diff --git a/SearchBox/SearchBox/index.ts b/SearchBox/SearchBox/index.ts index ca35409f..93e0f397 100644 --- a/SearchBox/SearchBox/index.ts +++ b/SearchBox/SearchBox/index.ts @@ -9,6 +9,7 @@ export class SearchBox implements ComponentFramework.ReactControl; notifyOutputChanged: ((debounce?: boolean) => void) | null; + notifyOutputChangedNoDebounce: () => void; searchTextValue: string; defaultValue: string; setFocus = ''; @@ -30,6 +31,7 @@ export class SearchBox implements ComponentFramework.ReactControl, notifyOutputChanged: () => void): void { this.notifyOutputChanged = notifyOutputChanged; + this.notifyOutputChangedNoDebounce = notifyOutputChanged; this.context = context; this.context.mode.trackContainerResize(true); if (this.notifyOutputChanged) { @@ -53,7 +55,7 @@ export class SearchBox implements ComponentFramework.ReactControl Default value to set for the search box. This can be used only once + + Border color + \ No newline at end of file