MCPcopy Index your code
hub / github.com/react-component/input / triggerChange

Function triggerChange

src/Input.tsx:103–138  ·  view source on GitHub ↗
(
    e:
      | React.ChangeEvent<HTMLInputElement>
      | React.CompositionEvent<HTMLInputElement>,
    currentValue: string,
    info: ChangeEventInfo,
  )

Source from the content-addressed store, hash-verified

101 }, [disabled]);
102
103 const triggerChange = (
104 e:
105 | React.ChangeEvent<HTMLInputElement>
106 | React.CompositionEvent<HTMLInputElement>,
107 currentValue: string,
108 info: ChangeEventInfo,
109 ) => {
110 let cutValue = currentValue;
111
112 if (
113 !compositionRef.current &&
114 countConfig.exceedFormatter &&
115 countConfig.max &&
116 countConfig.strategy(currentValue) > countConfig.max
117 ) {
118 cutValue = countConfig.exceedFormatter(currentValue, {
119 max: countConfig.max,
120 });
121
122 if (currentValue !== cutValue) {
123 setSelection([
124 inputRef.current?.selectionStart || 0,
125 inputRef.current?.selectionEnd || 0,
126 ]);
127 }
128 } else if (info.source === 'compositionEnd') {
129 // Avoid triggering twice
130 // https://github.com/ant-design/ant-design/issues/46587
131 return;
132 }
133 setValue(cutValue);
134
135 if (inputRef.current) {
136 resolveOnChange(inputRef.current, e, onChange, cutValue);
137 }
138 };
139
140 useEffect(() => {
141 if (selection) {

Callers 2

onInternalChangeFunction · 0.85
onInternalCompositionEndFunction · 0.85

Calls 1

resolveOnChangeFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…