Combobox: using onfocus to open menu causes issues
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
Thank you for reaching out. Can you provide a codepen with the example?
https://codepen.io/tabansal/pen/ROepvj
If you click on ComboBox arrow, menu opens and closes quickly
The codepen example does not render. Can you double check?
It's working now, my system restarted. So link stopped working
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?
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?
@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 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.
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.