Skip to content

Commit

Permalink
fix(web): content & navigation list scroll on mobile (#1207)
Browse files Browse the repository at this point in the history
  • Loading branch information
amanharwara committed Jul 5, 2022
1 parent 82f3025 commit 37d765a
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 25 deletions.
6 changes: 1 addition & 5 deletions packages/encryption/src/Domain/Split/EncryptionSplit.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { Uuid } from '@standardnotes/common'
import {
DecryptedPayloadInterface,
EncryptedPayloadInterface,
PayloadInterface,
} from '@standardnotes/models'
import { DecryptedPayloadInterface, EncryptedPayloadInterface, PayloadInterface } from '@standardnotes/models'
import { EncryptionTypeSplit } from './EncryptionTypeSplit'
import { KeyedDecryptionSplit } from './KeyedDecryptionSplit'
import { KeyedEncryptionSplit } from './KeyedEncryptionSplit'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { SelectedItemsController } from '@/Controllers/SelectedItemsController'
import { NavigationController } from '@/Controllers/Navigation/NavigationController'
import { NotesController } from '@/Controllers/NotesController'
import { ElementIds } from '@/Constants/ElementIDs'
import { classNames } from '@/Utils/ConcatenateClassNames'

type Props = {
application: WebApplication
Expand Down Expand Up @@ -66,7 +67,11 @@ const ContentList: FunctionComponent<Props> = ({

return (
<div
className="infinite-scroll focus:shadow-none focus:outline-none"
className={classNames(
'infinite-scroll overflow-y-auto overflow-x-hidden focus:shadow-none focus:outline-none',
'md:overflow-y-hidden md:hover:overflow-y-auto',
'md:hover:[overflow-y:_overlay]',
)}
id={ElementIds.ContentList}
onScroll={onScroll}
onKeyDown={onKeyDown}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { ElementIds } from '@/Constants/ElementIDs'
import ContentListHeader from './Header/ContentListHeader'
import ResponsivePaneContent from '../ResponsivePane/ResponsivePaneContent'
import { AppPaneId } from '../ResponsivePane/AppPaneMetadata'
import { useResponsiveAppPane } from '../ResponsivePane/ResponsivePaneProvider'

type Props = {
accountMenuController: AccountMenuController
Expand All @@ -43,6 +44,8 @@ const ContentListView: FunctionComponent<Props> = ({
notesController,
selectionController,
}) => {
const { toggleAppPane } = useResponsiveAppPane()

const itemsViewPanelRef = useRef<HTMLDivElement>(null)

const {
Expand All @@ -65,13 +68,14 @@ const ContentListView: FunctionComponent<Props> = ({
[navigationController.selected?.uuid],
)

const addNewItem = useCallback(() => {
const addNewItem = useCallback(async () => {
if (isFilesSmartView) {
void filesController.uploadNewFile()
} else {
void createNewNote()
await createNewNote()
toggleAppPane(AppPaneId.Editor)
}
}, [filesController, createNewNote, isFilesSmartView])
}, [isFilesSmartView, filesController, createNewNote, toggleAppPane])

useEffect(() => {
/**
Expand All @@ -84,7 +88,7 @@ const ContentListView: FunctionComponent<Props> = ({
modifiers: [KeyboardModifier.Meta, KeyboardModifier.Ctrl],
onKeyDown: (event) => {
event.preventDefault()
addNewItem()
void addNewItem()
},
})

Expand Down Expand Up @@ -170,7 +174,7 @@ const ContentListView: FunctionComponent<Props> = ({
return (
<div
id="items-column"
className="sn-component section app-column app-column-second border-b border-solid border-border"
className="sn-component section app-column app-column-second flex flex-col border-b border-solid border-border"
aria-label={'Notes & Files'}
ref={itemsViewPanelRef}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import PanelResizer, { PanelSide, ResizeFinishCallback, PanelResizeType } from '
import SearchBar from '@/Components/SearchBar/SearchBar'
import ResponsivePaneContent from '@/Components/ResponsivePane/ResponsivePaneContent'
import { AppPaneId } from '@/Components/ResponsivePane/AppPaneMetadata'
import { classNames } from '@/Utils/ConcatenateClassNames'

type Props = {
application: WebApplication
Expand Down Expand Up @@ -59,7 +60,13 @@ const Navigation: FunctionComponent<Props> = ({ application }) => {
</div>
</div>
</div>
<div className="scrollable">
<div
className={classNames(
'h-full overflow-y-auto overflow-x-hidden',
'md:overflow-y-hidden md:hover:overflow-y-auto',
'md:hover:[overflow-y:_overlay]',
)}
>
<SmartViewsSection viewControllerManager={viewControllerManager} />
<TagsSection viewControllerManager={viewControllerManager} />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ class PanelResizer extends Component<Props, State> {
this.props.hoverable && 'hover:opacity-100',
this.props.side === PanelSide.Left && 'left-0 right-auto',
)}
onMouseDown={this.onMouseDown}
ref={this.resizerElementRef}
/>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const ResponsivePaneContent = ({ children, contentClassName, contentElementId, p
</button>
<div
id={contentElementId}
className={classNames('content', isSelectedPane ? 'h-full' : 'hidden flex-col md:flex', contentClassName)}
className={classNames('content flex flex-col', isSelectedPane ? 'h-full' : 'hidden md:flex', contentClassName)}
>
{children}
</div>
Expand Down
4 changes: 1 addition & 3 deletions packages/web/src/javascripts/Components/Tags/TagsList.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { ViewControllerManager } from '@/Services/ViewControllerManager'
import { isMobile } from '@/Utils'
import { SNTag } from '@standardnotes/snjs'
import { observer } from 'mobx-react-lite'
import { FunctionComponent, useCallback } from 'react'
import { DndProvider } from 'react-dnd'
import { HTML5Backend } from 'react-dnd-html5-backend'
import { TouchBackend } from 'react-dnd-touch-backend'
import RootTagDropZone from './RootTagDropZone'
import { TagsListItem } from './TagsListItem'

Expand All @@ -17,7 +15,7 @@ const TagsList: FunctionComponent<Props> = ({ viewControllerManager }: Props) =>
const tagsState = viewControllerManager.navigationController
const allTags = tagsState.allLocalRootTags

const backend = isMobile({ tablet: true }) ? TouchBackend : HTML5Backend
const backend = HTML5Backend

const openTagContextMenu = useCallback(
(posX: number, posY: number) => {
Expand Down
2 changes: 0 additions & 2 deletions packages/web/src/stylesheets/_items-column.scss
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@
}

.infinite-scroll {
@include minimal_scrollbar();
height: inherit;
background-color: var(--items-column-items-background-color);
}

Expand Down
7 changes: 0 additions & 7 deletions packages/web/src/stylesheets/_navigation.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
@import './scrollbar';

#navigation .scrollable {
@include minimal_scrollbar();
height: 100%;
}

$content-horizontal-padding: 16px;

#navigation {
Expand Down

0 comments on commit 37d765a

Please sign in to comment.