Skip to content

Commit 0d54108

Browse files
authored
Fix typescript migration bug, code should enter here to calcylate tip position also when width is undefined (casting to 0) (#1396)
1 parent e8e5447 commit 0d54108

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/components/hint/index.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,13 +363,15 @@ class Hint extends Component<HintProps, HintState> {
363363
tipPositionStyle.top = this.hintOffset - this.tipSize.height;
364364
}
365365

366-
if (this.targetLayout?.width && this.targetLayout?.x) {
367-
const targetMidWidth = this.targetLayout.width / 2;
366+
const layoutWidth = this.targetLayout?.width || 0;
367+
368+
if (this.targetLayout?.x) {
369+
const targetMidWidth = layoutWidth / 2;
368370
const tipMidWidth = this.tipSize.width / 2;
369371

370372
const leftPosition = this.useSideTip ? this.targetLayout.x : this.targetLayout.x + targetMidWidth - tipMidWidth;
371373
const rightPosition = this.useSideTip
372-
? this.containerWidth - this.targetLayout.x - this.targetLayout.width
374+
? this.containerWidth - this.targetLayout.x - layoutWidth
373375
: this.containerWidth - this.targetLayout.x - targetMidWidth - tipMidWidth;
374376
const targetPositionOnScreen = this.getTargetPositionOnScreen();
375377

0 commit comments

Comments
 (0)