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
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "office-ui-fabric-react",
"comment": "SearchBox: Clicks on element before input field set cursor to start of input text.",
"type": "minor"
}
],
"packageName": "office-ui-fabric-react",
"email": "lynam.emily@gmail.com"
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,14 @@ export class SearchBoxBase extends BaseComponent<ISearchBoxProps, ISearchBoxStat
className={ classNames.root }
onFocusCapture={ this._onFocusCapture }
>
<div className={ classNames.iconContainer }>
<Icon className={ classNames.icon } iconName='Search' />
<div
className={ classNames.iconContainer }
onClick={ this._onClickFocus }
>
<Icon
className={ classNames.icon }
iconName='Search'
/>
</div>
<input
id={ id }
Expand Down Expand Up @@ -142,6 +148,14 @@ export class SearchBoxBase extends BaseComponent<ISearchBoxProps, ISearchBoxStat
}
}

private _onClickFocus = () => {
const inputElement = this._inputElement.value;
if (inputElement) {
this.focus();
inputElement.selectionStart = inputElement.selectionEnd = 0;
}
}

private _onFocusCapture = (ev: React.FocusEvent<HTMLElement>) => {
this.setState({
hasFocus: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ export function getStyles(props: ISearchBoxStyleProps): ISearchBoxStyles {
width: 32,
textAlign: 'center',
transition: `width ${AnimationVariables.durationValue1}`,
color: palette.themePrimary
color: palette.themePrimary,
cursor: 'text'
},
hasFocus && {
width: 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ exports[`SearchBox renders SearchBox correctly 1`] = `
ms-SearchBox-iconContainer
{
color: #0078d4;
cursor: text;
display: flex;
flex-direction: column;
flex-shrink: 0;
Expand All @@ -53,6 +54,7 @@ exports[`SearchBox renders SearchBox correctly 1`] = `
transition: width 0.167s;
width: 32px;
}
onClick={[Function]}
>
<i
aria-hidden={true}
Expand Down