Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect user display name tooltip position in money request confirmation page #23990

Merged
merged 1 commit into from
Aug 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions src/components/DisplayNames/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class DisplayNames extends PureComponent {
this.state = {
isEllipsisActive: false,
};
this.setContainerLayout = this.setContainerLayout.bind(this);
this.getTooltipShiftX = this.getTooltipShiftX.bind(this);
}

Expand All @@ -25,15 +24,6 @@ class DisplayNames extends PureComponent {
});
}

/**
* Set the container layout for post calculations
*
* @param {*} {nativeEvent}
*/
setContainerLayout({nativeEvent}) {
this.containerLayout = nativeEvent.layout;
}

/**
* We may need to shift the Tooltip horizontally as some of the inline text wraps well with ellipsis,
* but their container node overflows the parent view which causes the tooltip to be misplaced.
Expand All @@ -47,11 +37,11 @@ class DisplayNames extends PureComponent {
* @returns {Number} Distance to shift the tooltip horizontally
*/
getTooltipShiftX(index) {
// Only shift the tooltip in case the containerLayout or Refs to the text node are available
if (!this.containerLayout || !this.childRefs[index]) {
// Only shift the tooltip in case the container ref or Refs to the text node are available
if (!this.containerRef || !this.childRefs[index]) {
return;
}
const {width: containerWidth, left: containerLeft} = this.containerLayout;
const {width: containerWidth, left: containerLeft} = this.containerRef.getBoundingClientRect();

// We have to return the value as Number so we can't use `measureWindow` which takes a callback
const {width: textNodeWidth, left: textNodeLeft} = this.childRefs[index].getBoundingClientRect();
Expand Down Expand Up @@ -81,7 +71,6 @@ class DisplayNames extends PureComponent {
// Tokenization of string only support prop numberOfLines on Web
<Text
style={[...this.props.textStyles, styles.pRelative]}
onLayout={this.setContainerLayout}
numberOfLines={this.props.numberOfLines || undefined}
ref={(el) => (this.containerRef = el)}
>
Expand Down
Loading