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:
parent
63fd8101f2
commit
477aecd0e4
@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
@ -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
|
||||
})
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@ -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 });
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user