diff --git a/app/assets/icons/ic-add.svg b/app/assets/icons/ic-add.svg index d92c119a2..b785d2267 100644 --- a/app/assets/icons/ic-add.svg +++ b/app/assets/icons/ic-add.svg @@ -1,3 +1,3 @@ - + diff --git a/app/assets/javascripts/app.ts b/app/assets/javascripts/app.ts index d939bba17..49fcb298c 100644 --- a/app/assets/javascripts/app.ts +++ b/app/assets/javascripts/app.ts @@ -58,7 +58,6 @@ import { delayHide, elemReady, fileChange, - infiniteScroll, lowercase, selectOnFocus, snEnter, @@ -150,7 +149,6 @@ const startApplication: StartApplication = async function startApplication( .directive('delayHide', delayHide) .directive('elemReady', elemReady) .directive('fileChange', fileChange) - .directive('infiniteScroll', [infiniteScroll]) .directive('lowercase', lowercase) .directive('selectOnFocus', ['$window', selectOnFocus]) .directive('snEnter', snEnter); diff --git a/app/assets/javascripts/components/Navigation.tsx b/app/assets/javascripts/components/Navigation.tsx index b3e5dcfd4..b3576ac0f 100644 --- a/app/assets/javascripts/components/Navigation.tsx +++ b/app/assets/javascripts/components/Navigation.tsx @@ -12,27 +12,35 @@ import { PANEL_NAME_NAVIGATION } from '@/views/constants'; import { PrefKey } from '@standardnotes/snjs'; import { observer } from 'mobx-react-lite'; import { FunctionComponent } from 'preact'; -import { useCallback, useEffect, useMemo, useState } from 'preact/hooks'; +import { useCallback, useMemo, useState } from 'preact/hooks'; import { PremiumModalProvider } from './Premium'; type Props = { application: WebApplication; }; +const NAVIGATION_SELECTOR = 'navigation'; + +const useNavigationPanelRef = (): [HTMLDivElement | null, () => void] => { + const [panelRef, setPanelRefInternal] = useState(null); + + const setPanelRefPublic = useCallback(() => { + const elem = document.querySelector( + NAVIGATION_SELECTOR + ) as HTMLDivElement | null; + setPanelRefInternal(elem); + }, [setPanelRefInternal]); + + return [panelRef, setPanelRefPublic]; +}; + export const Navigation: FunctionComponent = observer( ({ application }) => { const appState = useMemo(() => application.getAppState(), [application]); const componentViewer = appState.foldersComponentViewer; const enableNativeSmartTagsFeature = appState.features.enableNativeSmartTagsFeature; - const [panelRef, setPanelRef] = useState(null); - - useEffect(() => { - const elem = document.querySelector( - 'navigation' - ) as HTMLDivElement | null; - setPanelRef(elem); - }, [setPanelRef]); + const [panelRef, setPanelRef] = useNavigationPanelRef(); const onCreateNewTag = useCallback(() => { appState.tags.createNewTemplate(); @@ -53,10 +61,10 @@ export const Navigation: FunctionComponent = observer( return (
{componentViewer ? (
@@ -69,8 +77,8 @@ export const Navigation: FunctionComponent = observer(
) : ( -
-
+