diff --git a/components/brave_new_tab_ui/components/default/widget/index.tsx b/components/brave_new_tab_ui/components/default/widget/index.tsx index f12762034580..fc70983ea65e 100644 --- a/components/brave_new_tab_ui/components/default/widget/index.tsx +++ b/components/brave_new_tab_ui/components/default/widget/index.tsx @@ -23,6 +23,7 @@ export interface WidgetProps { } export interface WidgetState { + hoveringOverMenu: boolean widgetMenuPersist: boolean } @@ -31,6 +32,7 @@ const createWidget =

(WrappedComponent: React.ComponentType

constructor (props: P & WidgetProps) { super(props) this.state = { + hoveringOverMenu: false, widgetMenuPersist: false } } @@ -40,11 +42,27 @@ const createWidget =

(WrappedComponent: React.ComponentType

} persistWidgetHover = () => { - this.setState({ widgetMenuPersist: true }) + this.setState({ + hoveringOverMenu: true, + widgetMenuPersist: true + }) + } + + disableHover = () => { + this.setState({ hoveringOverMenu: false }) } unpersistWidgetHover = () => { - this.setState({ widgetMenuPersist: false }) + if (!this.state.hoveringOverMenu) { + this.setState({ widgetMenuPersist: false }) + } + } + + disableMenu = () => { + this.setState({ + hoveringOverMenu: false, + widgetMenuPersist: false + }) } render () { @@ -67,7 +85,7 @@ const createWidget =

(WrappedComponent: React.ComponentType

(WrappedComponent: React.ComponentType

hideWidget={hideWidget as HideWidgetFunction} unpersistWidgetHover={this.unpersistWidgetHover} onMouseEnter={this.persistWidgetHover} + onMouseLeave={this.disableMenu} /> } diff --git a/components/brave_new_tab_ui/components/default/widget/widgetMenu.tsx b/components/brave_new_tab_ui/components/default/widget/widgetMenu.tsx index d44efb1b6033..ee4c77a12fc9 100644 --- a/components/brave_new_tab_ui/components/default/widget/widgetMenu.tsx +++ b/components/brave_new_tab_ui/components/default/widget/widgetMenu.tsx @@ -24,6 +24,7 @@ interface Props { widgetTitle?: string onLearnMore?: () => void onMouseEnter: () => void + onMouseLeave: () => void onDisconnect?: () => void onRefreshData?: () => void } @@ -65,6 +66,11 @@ export default class WidgetMenu extends React.PureComponent { this.setState({ showMenu: false }) } + onMouseLeave = () => { + this.closeMenu() + this.props.onMouseLeave() + } + unmountWidget = () => { this.props.hideWidget() this.props.unpersistWidgetHover() @@ -101,6 +107,7 @@ export default class WidgetMenu extends React.PureComponent { {showMenu &&