Skip to content

Commit

Permalink
[CP-2801] Back and Forward mouse buttons cause unexpected MDS behavior (
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarski authored Aug 23, 2024
1 parent 14a55ed commit 6e0eb2c
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ import BaseRoutes from "Core/core/components/apps/base-app/base-app-routes"
import BaseApp from "Core/core/components/apps/base-app/base-app.component"
import { RoutesHistoryProvider } from "shared/utils"
import useAltLinkDownloadPreventer from "Core/core/components/use-alt-link-download-preventer.hook"
import useBackForwardButtonPreventer from "Core/core/components/use-back-forward-button-preventer.hook"
import { ApiDeviceModals } from "generic-view/feature"

const BaseAppContainer: FunctionComponent = () => {
useAltLinkDownloadPreventer()
useBackForwardButtonPreventer()

return (
<Router history={history}>
Expand Down
2 changes: 2 additions & 0 deletions libs/core/core/components/apps/license-app.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import { FunctionComponent } from "Core/core/types/function-component.interface"
import { URL_MAIN } from "Core/__deprecated__/renderer/constants/urls"
import { LicenseUI } from "Core/settings/components/license/license-ui.component"
import useAltLinkDownloadPreventer from "Core/core/components/use-alt-link-download-preventer.hook"
import useBackForwardButtonPreventer from "Core/core/components/use-back-forward-button-preventer.hook"

const LicenseApp: FunctionComponent = () => {
useAltLinkDownloadPreventer()
useBackForwardButtonPreventer()

return (
<Router history={history}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import { FunctionComponent } from "Core/core/types/function-component.interface"
import { URL_MAIN } from "Core/__deprecated__/renderer/constants/urls"
import { PrivacyPolicyUI } from "Core/settings/components"
import useAltLinkDownloadPreventer from "Core/core/components/use-alt-link-download-preventer.hook"
import useBackForwardButtonPreventer from "Core/core/components/use-back-forward-button-preventer.hook"

const PrivacyPolicyApp: FunctionComponent = () => {
useAltLinkDownloadPreventer()
useBackForwardButtonPreventer()

return (
<Router history={history}>
Expand Down
2 changes: 2 additions & 0 deletions libs/core/core/components/apps/sar-app.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import { FunctionComponent } from "Core/core/types/function-component.interface"
import { URL_OVERVIEW } from "Core/__deprecated__/renderer/constants/urls"
import SarComponent from "Core/overview/components/pure-system/sar.component"
import useAltLinkDownloadPreventer from "Core/core/components/use-alt-link-download-preventer.hook"
import useBackForwardButtonPreventer from "Core/core/components/use-back-forward-button-preventer.hook"

const SarApp: FunctionComponent = () => {
useAltLinkDownloadPreventer()
useBackForwardButtonPreventer()

return (
<Router history={history}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import { FunctionComponent } from "Core/core/types/function-component.interface"
import { URL_MAIN } from "Core/__deprecated__/renderer/constants/urls"
import { TermsOfServiceUI } from "Core/settings/components"
import useAltLinkDownloadPreventer from "Core/core/components/use-alt-link-download-preventer.hook"
import useBackForwardButtonPreventer from "Core/core/components/use-back-forward-button-preventer.hook"

const TermsOfServiceApp: FunctionComponent = () => {
useAltLinkDownloadPreventer()
useBackForwardButtonPreventer()

return (
<Router history={history}>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Copyright (c) Mudita sp. z o.o. All rights reserved.
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/

import { useCallback, useEffect } from "react"

const useBackForwardButtonPreventer = () => {
const handleMouseUp = useCallback((event: MouseEvent) => {
if (event.button === 3 || event.button === 4) {
event.preventDefault()
}
}, [])

useEffect(() => {
document.addEventListener("mouseup", handleMouseUp)
return () => document.removeEventListener("mouseup", handleMouseUp)
}, [handleMouseUp])
}

export default useBackForwardButtonPreventer

0 comments on commit 6e0eb2c

Please sign in to comment.