Skip to content
Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"changes": [{
"packageName": "office-ui-fabric-react",
"comment": "Add clearButtonProps prop to SearchBox.types.ts with ariaLabel and ariaDescription. These are passed to the icon button in SearchBox.base.tsx",
"type": "minor"
}],
"packageName": "office-ui-fabric-react",
"email": "cohoov@microsoft.com"
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class SearchBoxBase extends BaseComponent<ISearchBoxProps, ISearchBoxStat
}

public render() {
let { labelText, className, disabled, underlined, getStyles, theme } = this.props;
let { labelText, className, disabled, underlined, getStyles, theme, clearButtonProps } = this.props;
let { value, hasFocus, id } = this.state;

const classNames = getClassNames(getStyles!, {
Expand Down Expand Up @@ -89,7 +89,13 @@ export class SearchBoxBase extends BaseComponent<ISearchBoxProps, ISearchBoxStat
/>
{ value!.length > 0 &&
<div className={ classNames.clearButton }>
<IconButton styles={ { root: { height: 'auto' }, icon: { fontSize: '12px' } } } onClick={ this._onClearClick } iconProps={ { iconName: 'Clear' } } />
<IconButton
styles={ { root: { height: 'auto' }, icon: { fontSize: '12px' } } }
onClick={ this._onClearClick }
iconProps={ { iconName: 'Clear' } }
ariaLabel={ clearButtonProps && clearButtonProps.ariaLabel }
ariaDescription={ clearButtonProps && clearButtonProps.ariaDescription }
/>
</div>
}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ export interface ISearchBoxProps extends React.InputHTMLAttributes<HTMLInputElem
*/
ariaLabel?: string;

/**
* The aria label of the clear button for the SearchBox for the benefit of screen readers.
*/
clearButtonAriaLabel?: string;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

we need to remove this. right ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done.

/**
* The props for the clear button.
*/
clearButtonProps?: ISearchBoxClearButtonProps;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should just be IButtonProps which should support whatever a button supports. That allows the caller to do things like put a data-automation-id on it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'd considered that but thought I'd start with the conservative approach of whitelisting properties. Is this the last blocking issue?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

To clarify: I will change this to ibuttonprops tomorrow, I'm just asking if there are other changes needed as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done.


/**
* Whether or not the SearchBox is underlined.
* @default false
Expand Down Expand Up @@ -96,4 +106,9 @@ export interface ISearchBoxStyles {
icon?: IStyle;
field?: IStyle;
clearButton?: IStyle;
}

export interface ISearchBoxClearButtonProps {
ariaLabel?: string;
ariaDescription?: string;
}