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
hideWidget={hideWidget as HideWidgetFunction}
unpersistWidgetHover={this.unpersistWidgetHover}
onMouseEnter={this.persistWidgetHover}
+ onMouseLeave={this.disableMenu}
/>
}