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: Tooltip and message date position #3864

Merged
merged 9 commits into from
Jul 13, 2021
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion src/components/DisplayNames/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class DisplayNames extends PureComponent {
<Tooltip
key={index}
text={tooltip}
containerStyle={styles.dInline}
containerStyles={[styles.dInline]}
Luke9389 marked this conversation as resolved.
Show resolved Hide resolved
shiftHorizontal={() => this.getTooltipShiftX(index)}
>
{/* // We need to get the refs to all the names which will be used to correct
Expand Down
4 changes: 2 additions & 2 deletions src/components/Hoverable/HoverablePropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const propTypes = {

/** Styles to be assigned to the Hoverable Container */
// eslint-disable-next-line react/forbid-prop-types
containerStyle: PropTypes.object,
containerStyles: PropTypes.arrayOf(PropTypes.object),

/** Function that executes when the mouse moves over the children. */
onHoverIn: PropTypes.func,
Expand All @@ -22,7 +22,7 @@ const propTypes = {
};

const defaultProps = {
containerStyle: {},
containerStyles: [],
onHoverIn: () => {},
onHoverOut: () => {},
resetsOnClickOutside: false,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Hoverable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class Hoverable extends Component {
render() {
return (
<View
style={this.props.containerStyle}
style={this.props.containerStyles}
ref={el => this.wrapperView = el}
onMouseEnter={() => this.setIsHovered(true)}
onMouseLeave={() => this.setIsHovered(false)}
Expand Down
3 changes: 2 additions & 1 deletion src/components/Tooltip/TooltipPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const propTypes = {
text: PropTypes.string.isRequired,

/** Styles to be assigned to the Tooltip wrapper views */
containerStyle: PropTypes.object,
containerStyles: PropTypes.arrayOf(PropTypes.object),

/** Children to wrap with Tooltip. */
children: PropTypes.node.isRequired,
Expand All @@ -26,6 +26,7 @@ const propTypes = {
const defaultProps = {
shiftHorizontal: 0,
shiftVertical: 0,
containerStyles: [],
};

export {
Expand Down
4 changes: 2 additions & 2 deletions src/components/Tooltip/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,13 @@ class Tooltip extends PureComponent {
/>
)}
<Hoverable
containerStyle={this.props.containerStyle}
containerStyles={this.props.containerStyles}
onHoverIn={this.showTooltip}
onHoverOut={this.hideTooltip}
>
<View
ref={el => this.wrapperView = el}
style={this.props.containerStyle}
style={this.props.containerStyles}
>
{this.props.children}
</View>
Expand Down
23 changes: 20 additions & 3 deletions src/components/Tooltip/index.native.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
import React from 'react';
import {View} from 'react-native';
import PropTypes from 'prop-types';

// We can't use the common component for the Tooltip as Web implementation uses DOM specific method to
// render the View which is not present on the Mobile.
const propTypes = {
children: PropTypes.element,
/** Styles to be assigned to the Tooltip wrapper views */
containerStyles: PropTypes.arrayOf(PropTypes.object),

/** Children to wrap with Tooltip. */
children: PropTypes.node.isRequired,
rdjuric marked this conversation as resolved.
Show resolved Hide resolved
};

const defaultProps = {
containerStyles: [],
};

/**
* There is no native support for the Hover on the Mobile platform so we just return the enclosing childrens
* There is no native support for the Hover on the Mobile platform, but as we use the Tooltip as a
* container we must past pass that containerStyle to a simple View in order to avoid different
* styles across platforms.
rdjuric marked this conversation as resolved.
Show resolved Hide resolved
* @param {propTypes} props
* @returns {ReactNodeLike}
*/
const Tooltip = props => props.children;
const Tooltip = props => (
<View style={props.containerStyles}>
{props.children}
</View>
);

rdjuric marked this conversation as resolved.
Show resolved Hide resolved
Tooltip.propTypes = propTypes;
Tooltip.defaultProps = defaultProps;
Tooltip.displayName = 'Tooltip';
export default Tooltip;
rdjuric marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion src/pages/home/report/ReportActionItemFragment.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class ReportActionItemFragment extends React.PureComponent {
);
case 'TEXT':
return (
<Tooltip text={tooltipText} containerStyle={styles.w100}>
rdjuric marked this conversation as resolved.
Show resolved Hide resolved
<Tooltip text={tooltipText} containerStyles={[styles.flexShrink1]}>
<Text
selectable
numberOfLines={this.props.isSingleLine ? 1 : undefined}
Expand Down
3 changes: 2 additions & 1 deletion src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ const styles = {
alignItems: 'center',
display: 'flex',
flexDirection: 'row',
flexWrap: 'wrap',
flexWrap: 'nowrap',
},

chatItemMessageHeaderSender: {
Expand All @@ -890,6 +890,7 @@ const styles = {
},

chatItemMessageHeaderTimestamp: {
flexShrink: 0,
color: themeColors.textSupporting,
fontSize: variables.fontSizeSmall,
height: 24,
Expand Down
4 changes: 4 additions & 0 deletions src/styles/utilities/flex.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,8 @@ export default {
flexGrow4: {
flexGrow: 4,
},

flexShrink1: {
flexShrink: 1,
},
};