@primer/react 0.0.0-20260306180530 → 0.0.0-20260306180541

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @primer/react
2
2
 
3
- ## 0.0.0-20260306180530
3
+ ## 0.0.0-20260306180541
4
4
 
5
5
  ### Minor Changes
6
6
 
@@ -20,6 +20,8 @@
20
20
 
21
21
  - [#7624](https://github.com/primer/react/pull/7624) [`f6d4311`](https://github.com/primer/react/commit/f6d431194d217fbb7d456e58bcbbcbb434896fe1) Thanks [@llastflowers](https://github.com/llastflowers)! - Fix FormControl + SelectPanel accessible name to address SR issues
22
22
 
23
+ - [#7600](https://github.com/primer/react/pull/7600) [`f688fd5`](https://github.com/primer/react/commit/f688fd5541b0d6382c597c85b9c075fa384eaab6) Thanks [@hectahertz](https://github.com/hectahertz)! - perf(TextInput): skip redundant character counter updates
24
+
23
25
  - [#7617](https://github.com/primer/react/pull/7617) [`79c855a`](https://github.com/primer/react/commit/79c855abeb6f46d3fefafb236f00ea65dfcd1ed4) Thanks [@llastflowers](https://github.com/llastflowers)! - Push margin-top of TimelineBody +1px
24
26
 
25
27
  - [#7550](https://github.com/primer/react/pull/7550) [`9585669`](https://github.com/primer/react/commit/958566907a580b54b484ff2339b32315b8a3b4b7) Thanks [@hectahertz](https://github.com/hectahertz)! - perf(Spinner): replace Web Animations API with CSS animation-delay sync
@@ -1 +1 @@
1
- {"version":3,"file":"TextInput.d.ts","sourceRoot":"","sources":["../../src/TextInput/TextInput.tsx"],"names":[],"mappings":"AACA,OAAO,KAAwD,MAAM,OAAO,CAAA;AAE5E,OAAO,KAAK,EAAC,mBAAmB,IAAI,8BAA8B,EAAC,MAAM,sBAAsB,CAAA;AAO/F,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,yCAAyC,CAAA;A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M,MAAM,4BAA4B,GAAG;IACzC,uEAAuE;IACvE,IAAI,CAAC,EAAE,KAAK,CAAC,WAAW,CAAA;IACxB,2DAA2D;IAC3D,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;;;QAKI;IACJ,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CAAA;IAChD,0DAA0D;IAC1D,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,aAAa,CAAC,EAAE,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,SAAS,CAAA;IACnD;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,SAAS,CAAA;IACpD;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC,CAAA;IACvE;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB,GAAG,OAAO,CACT,IAAI,CACF,kBAAkB,EAChB,OAAO,GACP,UAAU,GACV,UAAU,GACV,WAAW,GACX,OAAO,GACP,UAAU,GACV,UAAU,GACV,SAAS,GACT,MAAM,GACN,kBAAkB,CACrB,CACF,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,KAAK,CAAC,KAAK,CAAC,wBAAwB,CAAC,OAAO,CAAC,EAAE,4BAA4B,CAAC,CAAA;;;;;;;;;;;AA+PzG,wBAGE"}
@@ -51,6 +51,10 @@ const TextInput = /*#__PURE__*/React.forwardRef(({
51
51
  const [isOverLimit, setIsOverLimit] = useState(false);
52
52
  const [screenReaderMessage, setScreenReaderMessage] = useState('');
53
53
  const characterCounterRef = useRef(null);
54
+ const lastCountedLengthRef = useRef(null);
55
+ const lastCharacterCountRef = useRef('');
56
+ const lastIsOverLimitRef = useRef(false);
57
+ const lastScreenReaderMessageRef = useRef('');
54
58
 
55
59
  // this class is necessary to style FilterSearch, plz no touchy!
56
60
  const wrapperClasses = clsx(className, 'TextInput-wrapper');
@@ -84,17 +88,31 @@ const TextInput = /*#__PURE__*/React.forwardRef(({
84
88
  if (characterLimit) {
85
89
  characterCounterRef.current = new CharacterCounter({
86
90
  onCountUpdate: (count, overLimit, message) => {
87
- setCharacterCount(message);
88
- setIsOverLimit(overLimit);
91
+ if (message !== lastCharacterCountRef.current) {
92
+ lastCharacterCountRef.current = message;
93
+ setCharacterCount(message);
94
+ }
95
+ if (overLimit !== lastIsOverLimitRef.current) {
96
+ lastIsOverLimitRef.current = overLimit;
97
+ setIsOverLimit(overLimit);
98
+ }
89
99
  },
90
100
  onScreenReaderAnnounce: message_0 => {
91
- setScreenReaderMessage(message_0);
101
+ if (message_0 !== lastScreenReaderMessageRef.current) {
102
+ lastScreenReaderMessageRef.current = message_0;
103
+ setScreenReaderMessage(message_0);
104
+ }
92
105
  }
93
106
  });
107
+ lastCountedLengthRef.current = null;
94
108
  return () => {
95
109
  var _characterCounterRef$;
96
110
  (_characterCounterRef$ = characterCounterRef.current) === null || _characterCounterRef$ === void 0 ? void 0 : _characterCounterRef$.cleanup();
97
111
  characterCounterRef.current = null;
112
+ lastCountedLengthRef.current = null;
113
+ lastCharacterCountRef.current = '';
114
+ lastIsOverLimitRef.current = false;
115
+ lastScreenReaderMessageRef.current = '';
98
116
  };
99
117
  }
100
118
  }, [characterLimit]);
@@ -103,14 +121,22 @@ const TextInput = /*#__PURE__*/React.forwardRef(({
103
121
  useEffect(() => {
104
122
  if (characterLimit && characterCounterRef.current) {
105
123
  const currentValue = value !== undefined ? String(value) : defaultValue !== undefined ? String(defaultValue) : '';
106
- characterCounterRef.current.updateCharacterCount(currentValue.length, characterLimit);
124
+ const currentLength = currentValue.length;
125
+ if (currentLength !== lastCountedLengthRef.current) {
126
+ lastCountedLengthRef.current = currentLength;
127
+ characterCounterRef.current.updateCharacterCount(currentLength, characterLimit);
128
+ }
107
129
  }
108
130
  }, [value, defaultValue, characterLimit]);
109
131
 
110
132
  // Handle input change with character counter
111
133
  const handleInputChange = useCallback(e_2 => {
112
134
  if (characterLimit && characterCounterRef.current) {
113
- characterCounterRef.current.updateCharacterCount(e_2.target.value.length, characterLimit);
135
+ const currentLength_0 = e_2.target.value.length;
136
+ if (currentLength_0 !== lastCountedLengthRef.current) {
137
+ lastCountedLengthRef.current = currentLength_0;
138
+ characterCounterRef.current.updateCharacterCount(currentLength_0, characterLimit);
139
+ }
114
140
  }
115
141
  onChange === null || onChange === void 0 ? void 0 : onChange(e_2);
116
142
  }, [onChange, characterLimit]);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@primer/react",
3
3
  "type": "module",
4
- "version": "0.0.0-20260306180530",
4
+ "version": "0.0.0-20260306180541",
5
5
  "description": "An implementation of GitHub's Primer Design System using React",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",