fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

SearchBox component: a cursor can't be placed after the first letter

Open argrygor opened this issue 4 years ago • 4 comments

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

argrygor avatar Dec 06 '21 23:12 argrygor

+1 Here's a GIF of the issue. CursorNot Working

raj-pat avatar Dec 06 '21 23:12 raj-pat

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:

image

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 avatar Dec 07 '21 13:12 layershifter

@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: fix1

argrygor avatar Dec 07 '21 16:12 argrygor

@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: fix1

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.

layershifter avatar Dec 07 '21 16:12 layershifter