SearchBox component: a cursor can't be placed after the first letter
To reproduce: https://developer.microsoft.com/en-us/fluentui#/controls/web/searchbox Type anything in the search box component. Try to place cursor after the 1st letter
Actual behavior:
The cursor is placed before the 1st letter. All other letters work properly.
Expected behavior:
Should be possible to place cursor at any position
Priorities and help requested:
Requested priority: High
Products/sites affected: all products
+1
Here's a GIF of the issue.

I checked and the problem is present in both v7 & v8.
A codepen for v8: https://codepen.io/layershifter/pen/VwMaayB
The problem is caused by onClickFocus handler for icon:

Matching place in code:
https://github.com/microsoft/fluentui/blob/7cb2a5d8db1b6a1ddb638aa82d5815ab5ae84e69/packages/react/src/components/SearchBox/SearchBox.base.tsx#L131-L136
This happens because icon only changes opacity, but still handles events. A fix is to set in this case pointer-events: none:
.ms-SearchBox.is-active .ms-SearchBox-icon {
pointer-events: none;
}
https://codepen.io/layershifter/pen/eYGZZQR
I will submit a PR to fix it.
@layershifter thank you for a prompt response! Unfortunately, the fix doesn't solve all cases. It works if a cursor is already in the search box. However, during the first placement, it still doesn't work properly. Steps to reproduce:
- type something
- click outside of the search
- try to place cursor after 1st letter
Here is the gif:

@layershifter thank you for a prompt response! Unfortunately, the fix doesn't solve all cases. It works if a cursor is already in the search box. However, during the first placement, it still doesn't work properly. Steps to reproduce:
- type something
- click outside of the search
- try to place cursor after 1st letter
Here is the gif:
Hmm... Good catch 👍 One more override solves that problem:
.ms-SearchBox:hover .ms-SearchBox-icon {
pointer-events: none;
}
https://codepen.io/layershifter/pen/oNGxZrw
I will update the PR itself.