1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

fix cannot leave preferences

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2021-03-17 10:06:51 -04:00
parent 63fd8101f2
commit 477aecd0e4
4 changed files with 10 additions and 6 deletions

View File

@ -19,7 +19,7 @@ export interface RegisteredAppPreference extends AppPreferenceRegistration {
export class AppPreferenceRegistry extends BaseRegistry<AppPreferenceRegistration, RegisteredAppPreference> {
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,
};
}

View File

@ -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
})

View File

@ -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
}
}

View File

@ -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 });
});