diff --git a/src/extensions/registries/app-preference-registry.ts b/src/extensions/registries/app-preference-registry.ts index d702797c1d..e6b5d93cb2 100644 --- a/src/extensions/registries/app-preference-registry.ts +++ b/src/extensions/registries/app-preference-registry.ts @@ -19,7 +19,7 @@ export interface RegisteredAppPreference extends AppPreferenceRegistration { export class AppPreferenceRegistry extends BaseRegistry { getRegisteredItem(item: AppPreferenceRegistration): RegisteredAppPreference { return { - id: item.id || item.title.toLowerCase().replaceAll(/[^0-9a-zA-Z]+/, "-"), + id: item.id || item.title.toLowerCase().replace(/[^0-9a-zA-Z]+/g, "-"), ...item, }; } diff --git a/src/renderer/components/+preferences/preferences.tsx b/src/renderer/components/+preferences/preferences.tsx index 16a931e98a..eada7eb41e 100644 --- a/src/renderer/components/+preferences/preferences.tsx +++ b/src/renderer/components/+preferences/preferences.tsx @@ -33,8 +33,12 @@ export class Preferences extends React.Component { componentDidMount() { disposeOnUnmount(this, [ reaction(() => navigation.location.hash, hash => { - document.getElementById(hash.slice(1))?.scrollIntoView(); - navigation.location.hash = ""; + const fragment = hash.slice(1); // hash is /^(#\w.)?$/ + + if (fragment) { + // ignore empty framents + document.getElementById(fragment)?.scrollIntoView(); + } }, { fireImmediately: true }) diff --git a/src/renderer/navigation/helpers.ts b/src/renderer/navigation/helpers.ts index 0eda77c629..399eee6325 100644 --- a/src/renderer/navigation/helpers.ts +++ b/src/renderer/navigation/helpers.ts @@ -5,11 +5,11 @@ import { clusterViewRoute, IClusterViewRouteParams } from "../components/cluster import { navigation } from "./history"; export function navigate(location: LocationDescriptor) { - const currentLocation = navigation.getPath(); + const currentLocation = navigation.location.pathname; navigation.push(location); - if (currentLocation === navigation.getPath()) { + if (currentLocation === navigation.location.pathname) { navigation.goBack(); // prevent sequences of same url in history } } diff --git a/src/renderer/navigation/history.ts b/src/renderer/navigation/history.ts index f12b89f365..c1ce34625b 100644 --- a/src/renderer/navigation/history.ts +++ b/src/renderer/navigation/history.ts @@ -10,5 +10,5 @@ navigation.listen((location, action) => { const isClusterView = !process.isMainFrame; const domain = global.location.href; - logger.debug(`[NAVIGATION]: ${action}`, { isClusterView, domain, location }); + logger.debug(`[NAVIGATION]: ${action}-ing. Current is now:`, { isClusterView, domain, location }); });