@hsu-react/ui 0.0.15 → 0.0.16

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.
@@ -107,6 +107,8 @@ var TextEllipsis = function TextEllipsis(_ref) {
107
107
  };
108
108
  var textContent = getTextContent(children);
109
109
  var update = function update() {
110
+ // Detached nodes measure 0/0 — never let them overwrite a live measurement
111
+ if (!element.isConnected) return;
110
112
  var isTextOverflow = element.scrollWidth > element.clientWidth || element.scrollHeight > element.clientHeight;
111
113
  setIsOverflow(isTextOverflow);
112
114
  setMeasuredWidth(element.clientWidth);
@@ -179,24 +181,24 @@ var TextEllipsis = function TextEllipsis(_ref) {
179
181
  })]
180
182
  });
181
183
 
182
- // Show the Tooltip only when overflowing and not disabled
183
- if (isOverflow && !disabled) {
184
- return /*#__PURE__*/_jsx(Tooltip, _objectSpread(_objectSpread({
185
- arrow: false,
186
- placement: "bottomLeft"
187
- }, restTooltipConfig), {}, {
188
- title: tooltipTitle,
189
- styles: _objectSpread({
190
- body: {
191
- width: tooltipWidth,
192
- overflow: "auto",
193
- maxHeight: "300px",
194
- whiteSpace: "pre-wrap"
195
- }
196
- }, styles),
197
- children: content
198
- }));
199
- }
200
- return content;
184
+ // Always keep the Tooltip wrapper mounted and toggle via title:
185
+ // conditionally wrapping remounts the text DOM when isOverflow flips, which detaches
186
+ // the node the measurement effect's ResizeObserver holds — its final callback then
187
+ // reads 0/0 from the detached node and resets isOverflow, so the Tooltip never shows.
188
+ return /*#__PURE__*/_jsx(Tooltip, _objectSpread(_objectSpread({
189
+ arrow: false,
190
+ placement: "bottomLeft"
191
+ }, restTooltipConfig), {}, {
192
+ title: isOverflow && !disabled ? tooltipTitle : undefined,
193
+ styles: _objectSpread({
194
+ body: {
195
+ width: tooltipWidth,
196
+ overflow: "auto",
197
+ maxHeight: "300px",
198
+ whiteSpace: "pre-wrap"
199
+ }
200
+ }, styles),
201
+ children: content
202
+ }));
201
203
  };
202
204
  export default TextEllipsis;
@@ -87,6 +87,8 @@ const TextEllipsis = ({
87
87
  };
88
88
  const textContent = getTextContent(children);
89
89
  const update = () => {
90
+ // Detached nodes measure 0/0 — never let them overwrite a live measurement
91
+ if (!element.isConnected) return;
90
92
  const isTextOverflow = element.scrollWidth > element.clientWidth || element.scrollHeight > element.clientHeight;
91
93
  setIsOverflow(isTextOverflow);
92
94
  setMeasuredWidth(element.clientWidth);
@@ -157,25 +159,25 @@ const TextEllipsis = ({
157
159
  })]
158
160
  });
159
161
 
160
- // Show the Tooltip only when overflowing and not disabled
161
- if (isOverflow && !disabled) {
162
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Tooltip, {
163
- arrow: false,
164
- placement: "bottomLeft",
165
- ...restTooltipConfig,
166
- title: tooltipTitle,
167
- styles: {
168
- body: {
169
- width: tooltipWidth,
170
- overflow: "auto",
171
- maxHeight: "300px",
172
- whiteSpace: "pre-wrap"
173
- },
174
- ...styles
162
+ // Always keep the Tooltip wrapper mounted and toggle via title:
163
+ // conditionally wrapping remounts the text DOM when isOverflow flips, which detaches
164
+ // the node the measurement effect's ResizeObserver holds — its final callback then
165
+ // reads 0/0 from the detached node and resets isOverflow, so the Tooltip never shows.
166
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Tooltip, {
167
+ arrow: false,
168
+ placement: "bottomLeft",
169
+ ...restTooltipConfig,
170
+ title: isOverflow && !disabled ? tooltipTitle : undefined,
171
+ styles: {
172
+ body: {
173
+ width: tooltipWidth,
174
+ overflow: "auto",
175
+ maxHeight: "300px",
176
+ whiteSpace: "pre-wrap"
175
177
  },
176
- children: content
177
- });
178
- }
179
- return content;
178
+ ...styles
179
+ },
180
+ children: content
181
+ });
180
182
  };
181
183
  var _default = exports.default = TextEllipsis;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hsu-react/ui",
3
- "version": "0.0.15",
3
+ "version": "0.0.16",
4
4
  "description": "一套基于 React + Ant Design 的中后台业务组件库",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -109,6 +109,8 @@ const TextEllipsis: React.FC<TextEllipsisProps> = ({
109
109
  const textContent = getTextContent(children);
110
110
 
111
111
  const update = () => {
112
+ // Detached nodes measure 0/0 — never let them overwrite a live measurement
113
+ if (!element.isConnected) return;
112
114
  const isTextOverflow =
113
115
  element.scrollWidth > element.clientWidth ||
114
116
  element.scrollHeight > element.clientHeight;
@@ -189,30 +191,29 @@ const TextEllipsis: React.FC<TextEllipsisProps> = ({
189
191
  </span>
190
192
  );
191
193
 
192
- // Show the Tooltip only when overflowing and not disabled
193
- if (isOverflow && !disabled) {
194
- return (
195
- <Tooltip
196
- arrow={false}
197
- placement="bottomLeft"
198
- {...restTooltipConfig}
199
- title={tooltipTitle}
200
- styles={{
201
- body: {
202
- width: tooltipWidth,
203
- overflow: "auto",
204
- maxHeight: "300px",
205
- whiteSpace: "pre-wrap",
206
- },
207
- ...styles,
208
- }}
209
- >
210
- {content}
211
- </Tooltip>
212
- );
213
- }
214
-
215
- return content;
194
+ // Always keep the Tooltip wrapper mounted and toggle via title:
195
+ // conditionally wrapping remounts the text DOM when isOverflow flips, which detaches
196
+ // the node the measurement effect's ResizeObserver holds — its final callback then
197
+ // reads 0/0 from the detached node and resets isOverflow, so the Tooltip never shows.
198
+ return (
199
+ <Tooltip
200
+ arrow={false}
201
+ placement="bottomLeft"
202
+ {...restTooltipConfig}
203
+ title={isOverflow && !disabled ? tooltipTitle : undefined}
204
+ styles={{
205
+ body: {
206
+ width: tooltipWidth,
207
+ overflow: "auto",
208
+ maxHeight: "300px",
209
+ whiteSpace: "pre-wrap",
210
+ },
211
+ ...styles,
212
+ }}
213
+ >
214
+ {content}
215
+ </Tooltip>
216
+ );
216
217
  };
217
218
 
218
219
  export default TextEllipsis;