fix(mobile): explorer node touch optimization (#8101)

close AF-1338
This commit is contained in:
CatsJuice
2024-09-05 02:18:28 +00:00
parent 416faba2bc
commit 06552a1120
5 changed files with 40 additions and 37 deletions

View File

@@ -73,10 +73,7 @@ export const mobileRoot = style([
padding: '0 16px', padding: '0 16px',
selectors: { selectors: {
'&[data-collapsible="true"]:hover': { '&[data-collapsible="true"]:hover': {
backgroundColor: 'transparent', backgroundColor: 'none',
},
'&[data-collapsible="true"]:active': {
backgroundColor: cssVarV2('layer/background/hoverOverlay'),
}, },
}, },
}, },

View File

@@ -53,9 +53,11 @@ export const CategoryDivider = forwardRef(
/> />
) : null} ) : null}
</div> </div>
{mobile ? null : (
<div className={styles.actions} onClick={e => e.stopPropagation()}> <div className={styles.actions} onClick={e => e.stopPropagation()}>
{children} {children}
</div> </div>
)}
</div> </div>
); );
} }

View File

@@ -78,7 +78,7 @@ export const CollapsibleSection = ({
ref={headerRef} ref={headerRef}
className={clsx(header, headerClassName)} className={clsx(header, headerClassName)}
> >
{mobile ? null : actions} {actions}
</CategoryDivider> </CategoryDivider>
<Collapsible.Content <Collapsible.Content
data-testid="collapsible-section-content" data-testid="collapsible-section-content"

View File

@@ -189,7 +189,7 @@ export const mobileItemRoot = style([
gap: 12, gap: 12,
selectors: { selectors: {
'&:hover': { '&:hover': {
background: 'transparent', background: 'none',
}, },
'&:active': { '&:active': {
background: cssVar('hoverColor'), background: cssVar('hoverColor'),

View File

@@ -138,19 +138,21 @@ export const ExplorerTreeNode = ({
AffineDNDData & { draggable: { __cid: string } } AffineDNDData & { draggable: { __cid: string } }
>( >(
() => ({ () => ({
canDrag: () => !mobile,
data: { ...dndData?.draggable, __cid: cid }, data: { ...dndData?.draggable, __cid: cid },
dragPreviewPosition: 'pointer-outside', dragPreviewPosition: 'pointer-outside',
}), }),
[cid, dndData] [cid, dndData, mobile]
); );
const handleCanDrop = useMemo<DropTargetOptions<AffineDNDData>['canDrop']>( const handleCanDrop = useMemo<DropTargetOptions<AffineDNDData>['canDrop']>(
() => args => { () => args => {
if (mobile) return false;
if (!reorderable && args.treeInstruction?.type !== 'make-child') { if (!reorderable && args.treeInstruction?.type !== 'make-child') {
return false; return false;
} }
return (typeof canDrop === 'function' ? canDrop(args) : canDrop) ?? true; return (typeof canDrop === 'function' ? canDrop(args) : canDrop) ?? true;
}, },
[canDrop, reorderable] [canDrop, mobile, reorderable]
); );
const { const {
dropTargetRef, dropTargetRef,
@@ -347,6 +349,7 @@ export const ExplorerTreeNode = ({
</div> </div>
{postfix} {postfix}
{mobile ? null : (
<div <div
className={styles.postfix} className={styles.postfix}
onClick={e => { onClick={e => {
@@ -374,6 +377,7 @@ export const ExplorerTreeNode = ({
</Menu> </Menu>
)} )}
</div> </div>
)}
</div> </div>
{renameable && ( {renameable && (