mirror of
https://github.com/keeweb/keeweb.git
synced 2024-06-28 07:50:55 +02:00
settings scrolling
This commit is contained in:
parent
8d2e5b12aa
commit
809dd897f7
|
@ -2,7 +2,6 @@ import { Model } from 'util/model';
|
|||
import { MenuOption } from './menu-option';
|
||||
import { Keys } from 'const/keys';
|
||||
import { AlertConfig } from 'comp/ui/alerts';
|
||||
import { LocaleKey } from 'util/locale';
|
||||
import { InitWithFieldsOf } from 'util/types';
|
||||
import { File } from 'models/file';
|
||||
import { IdGenerator } from 'util/generators/id-generator';
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
import { FunctionComponent, h } from 'preact';
|
||||
import { SettingsGeneralView } from 'views/settings/settings-general-view';
|
||||
import { useModelWatcher } from 'util/ui/hooks';
|
||||
import { useModelField, useModelWatcher } from 'util/ui/hooks';
|
||||
import { AppSettings } from 'models/app-settings';
|
||||
import { Workspace } from 'models/workspace';
|
||||
|
||||
export const SettingsGeneral: FunctionComponent = () => {
|
||||
useModelWatcher(AppSettings);
|
||||
const selectedItem = useModelField(Workspace.menu, 'selectedItem');
|
||||
|
||||
return h(SettingsGeneralView, null);
|
||||
return h(SettingsGeneralView, {
|
||||
selectedMenuAnchor: selectedItem.anchor
|
||||
});
|
||||
};
|
||||
|
|
|
@ -7,10 +7,22 @@ import { SettingsGeneralAudit } from 'ui/settings/general/settings-general-audit
|
|||
import { SettingsGeneralLock } from 'ui/settings/general/settings-general-lock';
|
||||
import { SettingsGeneralStorage } from 'ui/settings/general/settings-general-storage';
|
||||
import { SettingsGeneralAdvanced } from 'ui/settings/general/settings-general-advanced';
|
||||
import { useLayoutEffect, useRef } from 'preact/hooks';
|
||||
|
||||
export const SettingsGeneralView: FunctionComponent<{
|
||||
selectedMenuAnchor: string | undefined;
|
||||
}> = ({ selectedMenuAnchor }) => {
|
||||
const contentRef = useRef<HTMLDivElement>();
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (selectedMenuAnchor) {
|
||||
const el = document.getElementById(selectedMenuAnchor);
|
||||
el?.scrollIntoView();
|
||||
}
|
||||
}, [selectedMenuAnchor]);
|
||||
|
||||
export const SettingsGeneralView: FunctionComponent = () => {
|
||||
return (
|
||||
<div class="settings__content">
|
||||
<div class="settings__content" ref={contentRef}>
|
||||
<h1 id="top">
|
||||
<i class="fa fa-cog settings__head-icon" /> {Locale.setGenTitle}
|
||||
</h1>
|
||||
|
|
Loading…
Reference in New Issue
Block a user