Back to Fluentui

@fluentui/react-combobox Migration Guide

packages/react-components/react-combobox/library/docs/Migration.md

4.40.2-hotfix212.1 KB
Original Source

@fluentui/react-combobox Migration Guide

Migration from v8 Dropdown

The v8 Dropdown component should be replaced with the v9 Select or v9 Dropdown component. The biggest change is that the v8 options: IDropdownOption[] prop is mapped to children in v9.

Property mapping

v8 Dropdownv9 Dropdown
options<Option> children
ariaLabelNative aria-* props
calloutPropspositioning + listbox
classNameclassName
componentRefref
defaultSelectedKeysdefaultSelectedOptions
disableddisabled
dropdownWidthlistbox slot styles
errorMessageHandled by Field
idid
labelHandled by Field or Label
multiSelectmultiselect
multiSelectDelimitercontrolled value
notifyOnReselectonClick on Option
onChangeonOptionSelect
onDismissonOpenChange
onRenderCaretDownexpandIcon slot
onRenderContainerlistbox slot
onRenderLabelHandled by Field
onRenderItemchildren
onRenderListlistbox slot
onRenderOption<Option> children
onRenderPlaceholderbutton slot
onRenderTitlebutton slot
openOnKeyboardFocuscontrolled open
panelPropsN/A
placeholderplaceholder
requiredrequired
selectedKey(s)selectedOptions
stylesmakeStyles or HTML style prop

From v8 ComboBox

The v8 ComboBox component should be replaced with the v9 Combobox component. The biggest differences are as follows:

  • The v8 options: IComboBoxOption[] prop is mapped to children in v9
  • Filtering is handled by authors by updating children
  • The v9 Combobox allows users to type any text while the input is focused. The value is updated to a matching option (or none) when blurred, unless freeform is true. If you don't need typing support, use Dropdown.

Property mapping

v8 ComboBoxv9 Combobox
options<Option> children
ariaLabelNative aria-* props
allowFreeInputalways true
allowFreeformfreeform
ariaDescribedByNative aria-* props
autocompletenot supported (yet)
autofillN/A
buttonIconPropsexpandIcon slot
calloutPropspositioning + listbox
caretDownButtonStylesexpandIcon slot
classNameclassName
comboBoxOptionStyles<Option> children
componentRefref
defaultSelectedKeysdefaultSelectedOptions
disableddisabled
dropdownMaxWidthlistbox slot styles
dropdownWidthlistbox slot styles
errorMessageHandled by Field
getClassNamesuseComboboxStyles hook
iconButtonPropsexpandIcon slot
idid
isButtonAriaHiddenexpandIcon slot, not recommended
labelHandled by Field or Label
multiSelectmultiselect
multiSelectDelimitercontrolled value
onChangeonOptionSelect*
onDismissonOpenChange
onInputValueChangeonChange*
onItemClickonClick on child <Option>s
onMenuDismissonOpenChange
onMenuDismissed
onMenuOpenonOpenChange
onPendingValueChanged
onRenderContainerlistbox slot
onRenderLabelHandled by Field
onRenderItemchildren
onRenderListlistbox slot
onRenderLowerContentchildren
onRenderOption<Option> children
onRenderPlaceholderbutton slot
onRenderTitlebutton slot
onRenderUpperContentchildren
onResolveOptionsN/A
onScrollToItem
openOnKeyboardFocuscontrolled open
panelPropsN/A
persistMenu
placeholderplaceholder
requiredrequired
scrollSelectedToTop
selectedKey(s)selectedOptions
shouldRestoreFocus
stylesmakeStyles or HTML style prop
textvalue
useComboBoxAsMenuWidthdefault behavior, listbox styles to override

*In v9, any native HTML properties supported on an <input> element may be set on <Combobox>, including the onChange handler. Because of this, the v8 onChange selection callback has been updated to onOptionSelect. The v9 Combobox's onChange event behavior is the same as for an <input> element, or the v9 Input control.

From v0 Dropdown

The v0 Dropdown should be replaced with the v9 Combobox if it allows typing with search: true, and by the v9 Dropdown if it does not. The most significant difference in moving to v9 is that the v0 Dropdown items are defined as child <Option>s of the v9 Combobox or Dropdown.

Property mapping

v0 Dropdownv9 Dropdown & Combobox
items<Option> children
activeSelectedIndexN/A
alignpositioning
checkableexpandIcon
checkableIndicatorexpandIcon children
classNameclassName
clearIndicatorN/A
clearable
defaultActiveSelectedIndexN/A
defaultActiveSelectedIndex
defaultOpendefaultOpen
defaultSearchQuerydefaultValue
defaultValuedefaultSelectedOptions
disableddisabled
errorHandled by Field
flipBoundarypositioning
fluidcustom styles
getA11ySelectionMessage
getA11yStatusMessage
headerMessagechildren
highlightFirstItemOnOpen
highlightedIndex
inlinecustom styles
invertedtheme or styles
itemToString<Option> children or text prop
itemToValue<Option> children or value prop
listlistbox
loadingchildren
loadingMessage
moveFocusOnTab
multiplemultiselect
noResultsMessagechildren
offsetpositioning
onActiveSelectedIndexChange
onBluronBlur
onChangeonOptionSelect*
onHighlightedIndexChangeonActiveOptionChange
onOpenChangeonOpenChange
onSearchQueryChangeonChange*
openopen
overflowBoundarylistbox styles
placeholderplaceholder
popperReflistbox slot's ref
positionpositioning
positionFixedlistbox styles
renderItemchildren
renderSelectedItemchildren or <Option> styles
searchuse Combobox instead of Dropdown
searchInputCombobox primary slot
searchQueryvalue
stylesmakeStyles or HTML style prop
toggleIndicatorexpandIcon
triggerButtonDropdown primary slot
valueselectedOptions
openopen

*In v9, any native HTML properties supported on an <input> element may be set on <Combobox>, including the onChange handler. Because of this, the v0 onChange selection callback has been updated to onOptionSelect. The v9 Combobox's onChange event behavior is the same as for an <input> element, or the v9 Input control.