diff --git a/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly.js b/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly.js index 18d3fbf25960..22a4ce75f99c 100644 --- a/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly.js +++ b/src/components/AnchorForCommentsOnly/BaseAnchorForCommentsOnly.js @@ -65,7 +65,7 @@ const BaseAnchorForCommentsOnly = (props) => { onPressIn={props.onPressIn} onPressOut={props.onPressOut} > - + linkRef = el} style={StyleSheet.flatten([props.style, defaultTextStyle])} diff --git a/src/components/AvatarWithIndicator.js b/src/components/AvatarWithIndicator.js index 6430d463a712..9bae6d9488c6 100644 --- a/src/components/AvatarWithIndicator.js +++ b/src/components/AvatarWithIndicator.js @@ -85,8 +85,8 @@ const AvatarWithIndicator = (props) => { const shouldShowIndicator = _.some(errorCheckingMethods, errorCheckingMethod => errorCheckingMethod()); return ( - - + + { {shouldShowIndicator && ( )} - - + + ); }; diff --git a/src/components/DisplayNames/index.js b/src/components/DisplayNames/index.js index fd23a011bf69..83def9ce8c05 100644 --- a/src/components/DisplayNames/index.js +++ b/src/components/DisplayNames/index.js @@ -95,7 +95,6 @@ class DisplayNames extends PureComponent { this.getTooltipShiftX(index)} > {/* // We need to get the refs to all the names which will be used to correct diff --git a/src/components/EmojiPicker/CategoryShortcutButton.js b/src/components/EmojiPicker/CategoryShortcutButton.js index 2c5f061327ae..33d5576c29ea 100644 --- a/src/components/EmojiPicker/CategoryShortcutButton.js +++ b/src/components/EmojiPicker/CategoryShortcutButton.js @@ -33,20 +33,19 @@ class CategoryShortcutButton extends PureComponent { render() { return ( - this.setState({isHighlighted: true})} - onHoverOut={() => this.setState({isHighlighted: false})} - style={({pressed}) => ([ - StyleUtils.getButtonBackgroundColorStyle(getButtonState(false, pressed)), - styles.categoryShortcutButton, - this.state.isHighlighted && styles.emojiItemHighlighted, - ])} + - this.setState({isHighlighted: true})} + onHoverOut={() => this.setState({isHighlighted: false})} + style={({pressed}) => ([ + StyleUtils.getButtonBackgroundColorStyle(getButtonState(false, pressed)), + styles.categoryShortcutButton, + this.state.isHighlighted && styles.emojiItemHighlighted, + ])} > - - + + ); } } diff --git a/src/components/FloatingActionButton.js b/src/components/FloatingActionButton.js index 2bc1d96d05ec..13275e5116a3 100644 --- a/src/components/FloatingActionButton.js +++ b/src/components/FloatingActionButton.js @@ -73,7 +73,7 @@ class FloatingActionButton extends PureComponent { }); return ( - + this.fabPressable = el} diff --git a/src/components/Hoverable/index.js b/src/components/Hoverable/index.js index 2f10cca0c1e3..2f275dd968fe 100644 --- a/src/components/Hoverable/index.js +++ b/src/components/Hoverable/index.js @@ -55,68 +55,55 @@ class Hoverable extends Component { } render() { - if (this.props.absolute && React.isValidElement(this.props.children)) { - return React.cloneElement(React.Children.only(this.props.children), { - ref: (el) => { - this.wrapperView = el; - - // Call the original ref, if any - const {ref} = this.props.children; - if (_.isFunction(ref)) { - ref(el); - } - }, - onMouseEnter: (el) => { - this.setIsHovered(true); - - // Call the original onMouseEnter, if any - const {onMouseEnter} = this.props.children; - if (_.isFunction(onMouseEnter)) { - onMouseEnter(el); - } - }, - onMouseLeave: (el) => { - this.setIsHovered(false); + const child = _.isFunction(this.props.children) + ? this.props.children(this.state.isHovered) + : this.props.children - // Call the original onMouseLeave, if any - const {onMouseLeave} = this.props.children; - if (_.isFunction(onMouseLeave)) { - onMouseLeave(el); - } - }, - onBlur: (el) => { - if (!this.wrapperView.contains(el.relatedTarget)) { - this.setIsHovered(false); - } - - // Call the original onBlur, if any - const {onBlur} = this.props.children; - if (_.isFunction(onBlur)) { - onBlur(el); - } - }, - }); + if (!React.isValidElement(child)) { + throw Error("Children is not a valid element."); } - return ( - this.wrapperView = el} - onMouseEnter={() => this.setIsHovered(true)} - onMouseLeave={() => this.setIsHovered(false)} - onBlur={(el) => { - if (this.wrapperView.contains(el.relatedTarget)) { - return; - } + + return React.cloneElement(React.Children.only(child), { + ref: (el) => { + this.wrapperView = el; + + // Call the original ref, if any + const {ref} = child; + if (_.isFunction(ref)) { + ref(el); + } + }, + onMouseEnter: (el) => { + console.log("ENTER") + this.setIsHovered(true); + + // Call the original onMouseEnter, if any + const {onMouseEnter} = child; + if (_.isFunction(onMouseEnter)) { + onMouseEnter(el); + } + }, + onMouseLeave: (el) => { + this.setIsHovered(false); + + // Call the original onMouseLeave, if any + const {onMouseLeave} = child; + if (_.isFunction(onMouseLeave)) { + onMouseLeave(el); + } + }, + onBlur: (el) => { + if (!this.wrapperView.contains(el.relatedTarget)) { this.setIsHovered(false); - }} - > - { // If this.props.children is a function, call it to provide the hover state to the children. - _.isFunction(this.props.children) - ? this.props.children(this.state.isHovered) - : this.props.children } - - ); + + // Call the original onBlur, if any + const {onBlur} = child; + if (_.isFunction(onBlur)) { + onBlur(el); + } + }, + }); } } diff --git a/src/components/MultipleAvatars.js b/src/components/MultipleAvatars.js index 6e30a2579a25..9a5099483fcc 100644 --- a/src/components/MultipleAvatars.js +++ b/src/components/MultipleAvatars.js @@ -69,8 +69,8 @@ const MultipleAvatars = (props) => { if (props.icons.length === 1 && !props.shouldStackHorizontally) { return ( - - + + { name={props.icons[0].name} type={props.icons[0].type} /> - - + + ); } @@ -127,7 +127,7 @@ const MultipleAvatars = (props) => { - + {/* View is necessary for tooltip to show for multiple avatars in LHN */} { style={secondAvatarStyles} > {props.icons.length === 2 ? ( - + { ) : ( - + diff --git a/src/components/OptionRow.js b/src/components/OptionRow.js index 532ae783bdd6..1bf7219df9d2 100644 --- a/src/components/OptionRow.js +++ b/src/components/OptionRow.js @@ -149,11 +149,7 @@ class OptionRow extends Component { errors={this.props.option.allReportErrors} shouldShowErrorMessages={false} > - + {hovered => ( touchableRef = el} diff --git a/src/components/Reactions/AddReactionBubble.js b/src/components/Reactions/AddReactionBubble.js index 3b57771311ab..0eb40ecccdc7 100644 --- a/src/components/Reactions/AddReactionBubble.js +++ b/src/components/Reactions/AddReactionBubble.js @@ -79,7 +79,7 @@ const AddReactionBubble = (props) => { }; return ( - + ( {_.map(CONST.QUICK_REACTIONS, emoji => ( - - // Note: focus is handled by the Pressable component in EmojiReactionBubble - + { displayName, pronouns, tooltip, }, index) => ( - + Navigation.navigate(ROUTES.getDetailsRoute(participants[index]))}> {displayName} diff --git a/src/components/SubscriptAvatar.js b/src/components/SubscriptAvatar.js index 6da3e918fec4..44b3eb723671 100644 --- a/src/components/SubscriptAvatar.js +++ b/src/components/SubscriptAvatar.js @@ -42,20 +42,22 @@ const defaultProps = { const SubscriptAvatar = props => ( - + + + - - + + ( name={props.secondaryAvatar.name} type={props.secondaryAvatar.type} /> - - + + ); diff --git a/src/components/Tooltip/index.js b/src/components/Tooltip/index.js index 104098b375f0..cb4c8b676759 100644 --- a/src/components/Tooltip/index.js +++ b/src/components/Tooltip/index.js @@ -1,6 +1,6 @@ import _ from 'underscore'; import React, {PureComponent} from 'react'; -import {Animated, View} from 'react-native'; +import {Animated} from 'react-native'; import TooltipRenderedOnPageBody from './TooltipRenderedOnPageBody'; import Hoverable from '../Hoverable'; import withWindowDimensions from '../withWindowDimensions'; @@ -37,6 +37,7 @@ class Tooltip extends PureComponent { this.getWrapperPosition = this.getWrapperPosition.bind(this); this.showTooltip = this.showTooltip.bind(this); this.hideTooltip = this.hideTooltip.bind(this); + this.isFocusable = this.isFocusable.bind(this); } componentDidUpdate(prevProps) { @@ -141,47 +142,50 @@ class Tooltip extends PureComponent { TooltipSense.deactivate(); } + /** + * Returns true if children is a focusable component. + * + * @returns {Boolean} + */ + isFocusable() { + const name = this.props.children.type.displayName; + const isPressableText = name === 'Text' && Boolean(this.props.children.props.onPress); + return isPressableText || ['TouchableOpacity', 'Pressable', 'TouchableWithoutFeedback'].includes(name); + } + render() { // Skip the tooltip and return the children if the text is empty, // we don't have a render function or the device does not support hovering if ((_.isEmpty(this.props.text) && this.props.renderTooltipContent == null) || !this.hasHoverSupport) { return this.props.children; } - let child = ( - this.wrapperView = el} - onBlur={this.hideTooltip} - focusable={this.props.focusable} - style={this.props.containerStyles} - > - {this.props.children} - - ); - - if (this.props.absolute && React.isValidElement(this.props.children)) { - child = React.cloneElement(React.Children.only(this.props.children), { - ref: (el) => { - this.wrapperView = el; - // Call the original ref, if any - const {ref} = this.props.children; - if (_.isFunction(ref)) { - ref(el); - } - }, - onBlur: (el) => { - this.hideTooltip(); - - // Call the original onBlur, if any - const {onBlur} = this.props.children; - if (_.isFunction(onBlur)) { - onBlur(el); - } - }, - focusable: true, - }); + if (!React.isValidElement(this.props.children)) { + throw Error("Children is not a valid element."); } + const child = React.cloneElement(React.Children.only(this.props.children), { + ref: (el) => { + this.wrapperView = el; + + // Call the original ref, if any + const {ref} = this.props.children; + if (_.isFunction(ref)) { + ref(el); + } + }, + onBlur: (el) => { + this.hideTooltip(); + + // Call the original onBlur, if any + const {onBlur} = this.props.children; + if (_.isFunction(onBlur)) { + onBlur(el); + } + }, + focusable: this.isFocusable(), + }); + return ( <> {this.state.isRendered && ( @@ -201,8 +205,6 @@ class Tooltip extends PureComponent { /> )} diff --git a/src/pages/home/report/ReportActionItemSingle.js b/src/pages/home/report/ReportActionItemSingle.js index 19d2cc05f58c..d6f5207e5a91 100644 --- a/src/pages/home/report/ReportActionItemSingle.js +++ b/src/pages/home/report/ReportActionItemSingle.js @@ -70,13 +70,13 @@ const ReportActionItemSingle = (props) => { return ( - showUserDetails(actorEmail)} - > - + + showUserDetails(actorEmail)} + > @@ -85,8 +85,8 @@ const ReportActionItemSingle = (props) => { source={avatarSource} /> - - + + {props.showHeader ? ( diff --git a/src/pages/settings/InitialSettingsPage.js b/src/pages/settings/InitialSettingsPage.js index 6d6db5a498f3..16cae58efe31 100755 --- a/src/pages/settings/InitialSettingsPage.js +++ b/src/pages/settings/InitialSettingsPage.js @@ -258,8 +258,8 @@ class InitialSettingsPage extends React.Component { - - + + @@ -269,9 +269,8 @@ class InitialSettingsPage extends React.Component { size={CONST.AVATAR_SIZE.LARGE} /> - - - + + diff --git a/src/pages/signin/SignInPageLayout/Footer.js b/src/pages/signin/SignInPageLayout/Footer.js index 0f6e099bc8c0..2b0f9cd7cf60 100644 --- a/src/pages/signin/SignInPageLayout/Footer.js +++ b/src/pages/signin/SignInPageLayout/Footer.js @@ -162,12 +162,15 @@ const Footer = (props) => { key={row.translationPath} > {hovered => ( - - {props.translate(row.translationPath)} - + + + {console.log(hovered)} + {props.translate(row.translationPath)} + + )} ))} diff --git a/src/pages/workspace/WorkspaceInitialPage.js b/src/pages/workspace/WorkspaceInitialPage.js index fea68a5af262..f4c071457e11 100644 --- a/src/pages/workspace/WorkspaceInitialPage.js +++ b/src/pages/workspace/WorkspaceInitialPage.js @@ -187,12 +187,12 @@ class WorkspaceInitialPage extends React.Component { - - + + - - + + {!_.isEmpty(this.props.policy.name) && ( {