react-select icon indicating copy to clipboard operation
react-select copied to clipboard

menuIsOpen does not work on mobile device

Open armspkt opened this issue 7 years ago • 5 comments

image

https://xi0os.csb.app/

https://codesandbox.io/s/react-codesandboxer-example-xi0os

When I try to use menuIsOpen props to control state react-select, it works only on desktop but for mobile look like event onClick does not fire.

armspkt avatar Oct 08 '19 10:10 armspkt

On mobile you should use the onTouchStart event instead of onClick. Here's a modified codesandbox with the update.

Xartok avatar Oct 12 '19 13:10 Xartok

@Xartok thanks for helping, but I don't understand why can't we just use onClick event. Why onClick still work on mobile when I use it with div element?

armspkt avatar Oct 13 '19 16:10 armspkt

Hi @armspkt,

I wanted to check in and see if you were still encountering this issue, or managed to find a reason why onClick wasn't working for you. We're triaging issues at the moment to sustain the project going forward.

bladey avatar Jun 23 '20 06:06 bladey

@bladey This issue still happens on the mobile device.

armspkt avatar Jun 23 '20 08:06 armspkt

Greetings @armspkt

I wanted to make sure I addressed your questions.

thanks for helping, but I don't understand why can't we just use onClick event.

  • The innerProps passed to the IndicatorsContainer contain eventBindings for onTouchEnd and onMouseDown.
  • These events fire earlier in the event lifecycle than onClick.
  • The attached methods prevent the event call from carrying through to the onClick event

Here is the code to see for yourself what is going on. https://github.com/JedWatson/react-select/blob/998c979b4ed51ee39b87c9b2f0f03da440017dcf/packages/react-select/src/Select.js#L952-#L968

Why onClick still work on mobile when I use it with div element?

The div likely doesn't have a onTouchEnd method calling event.stopPropagation, so your click event would be completely unimpeded.

Given that this is not a bug, I will be closing this issue, but am open to further discussing any questions.

ebonow avatar Dec 07 '20 20:12 ebonow