fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

Combobox: using onfocus to open menu causes issues

Open tabansal opened this issue 7 years ago • 9 comments

I'm using onFocus to open menu when user clicks inside input box to type something.

if (this.comboBoxRef && this.comboBoxRef.current && !this.state.isMenuOpen) { this.comboBoxRef.current.focus(true); }

But when I do this, clicking on arrowIcon inside combo box stops working. It opens the menu and quickly closes it.

Let me know if you need a fiddler to understand the issue

tabansal avatar Apr 23 '19 11:04 tabansal

Thank you for reaching out. Can you provide a codepen with the example?

apneer avatar Apr 23 '19 19:04 apneer

https://codepen.io/tabansal/pen/ROepvj

If you click on ComboBox arrow, menu opens and closes quickly

tabansal avatar Apr 24 '19 05:04 tabansal

The codepen example does not render. Can you double check?

apneer avatar Apr 24 '19 20:04 apneer

It's working now, my system restarted. So link stopped working

tabansal avatar Apr 25 '19 03:04 tabansal

This is one of blocking issues for us, can someone please look into it at priority? is there a way to increase priority this bug?

tabansal avatar Apr 29 '19 17:04 tabansal

I tried solution when you focus only if menu is not open. That did not work. it looks like the events are out of order. May be this should be an option on the component itself to be able to open menu on input click. @ecraig12345, can you see a solution to Tabas's issue?

apneer avatar Apr 29 '19 22:04 apneer

@tabansal it sounds like you're misusing the ComboBox. You should not need to expand the suggestions on focus, especially in an imperative way. Doing so would create an odd discrepancy in behavior that is different from other experiences.

Recommend that unless there is a pressing case for adding this functionality, you avoid doing this. If you agree, let's close this one. If you disagree, we need to hear what the use case is to better understand the need. Then from that we could extrapolate the right API contract, which is certainly not to use focus as a hacky way to expand the menu.

@jspurlin is the dev who worked on ComboBox and may have an opinion here.

dzearing avatar Apr 30 '19 18:04 dzearing

@dzearing We have a list of attributes that we display as a drop down using comboBox. The list is quite big so we provide a way to filter the list of options displayed when user types in combobox input. Also since we filter option based on user text the default list should open when user clicks inside input to type something.

I was using _onAutofillClick to open menu when user focuses inside input box. But based on response in https://github.com/OfficeDev/office-ui-fabric-react/issues/8606, I used onFocus to open menu.

Also it's a very common use case where we need to open menu as soon as user focuses in input box.

tabansal avatar Apr 30 '19 18:04 tabansal

We will use the original bug #8606 to make sure there is an official flag for this behavior. I've assigned that to @joschect to help with.

dzearing avatar Apr 30 '19 18:04 dzearing