MCPcopy
hub / github.com/Semantic-Org/Semantic-UI-React / Dropdown

Class Dropdown

src/modules/Dropdown/Dropdown.js:68–1462  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66 * @see Menu
67 */
68export default class Dropdown extends Component {
69 searchRef = createRef()
70 sizerRef = createRef()
71 ref = createRef()
72
73 getInitialAutoControlledState() {
74 return { focus: false, searchQuery: '' }
75 }
76
77 static getAutoControlledStateFromProps(nextProps, computedState, prevState) {
78 // These values are stored only for a comparison on next getAutoControlledStateFromProps()
79 const derivedState = { __options: nextProps.options, __value: computedState.value }
80
81 // The selected index is only dependent:
82 const shouldComputeSelectedIndex =
83 // On value change
84 !shallowEqual(prevState.__value, computedState.value) ||
85 // On option keys/values, we only check those properties to avoid recursive performance impacts.
86 // https://github.com/Semantic-Org/Semantic-UI-React/issues/3000
87 !_.isEqual(getKeyAndValues(nextProps.options), getKeyAndValues(prevState.__options))
88
89 if (shouldComputeSelectedIndex) {
90 derivedState.selectedIndex = getSelectedIndex({
91 additionLabel: nextProps.additionLabel,
92 additionPosition: nextProps.additionPosition,
93 allowAdditions: nextProps.allowAdditions,
94 deburr: nextProps.deburr,
95 multiple: nextProps.multiple,
96 search: nextProps.search,
97 selectedIndex: computedState.selectedIndex,
98
99 value: computedState.value,
100 options: nextProps.options,
101 searchQuery: computedState.searchQuery,
102 })
103 }
104
105 return derivedState
106 }
107
108 componentDidMount() {
109 debug('componentDidMount()')
110 const { open } = this.state
111
112 if (open) {
113 this.open(null, false)
114 }
115 }
116
117 shouldComponentUpdate(nextProps, nextState) {
118 return !shallowEqual(nextProps, this.props) || !shallowEqual(nextState, this.state)
119 }
120
121 componentDidUpdate(prevProps, prevState) {
122 // eslint-disable-line complexity
123 debug('componentDidUpdate()')
124 debug('to state:', objectDiff(prevState, this.state))
125

Callers

nothing calls this directly

Calls 13

doesNodeContainClickFunction · 0.90
useKeyOnlyFunction · 0.90
useKeyOrValueAndKeyFunction · 0.90
getUnhandledPropsFunction · 0.90
getElementTypeFunction · 0.90
getSelectedIndexFunction · 0.85
renderItemContentFunction · 0.85
getKeyOrValueFunction · 0.85
getBoundingClientRectMethod · 0.80
renderMenuMethod · 0.80
renderLabelFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…