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>
<div className={styles.actions} onClick={e => e.stopPropagation()}> {mobile ? null : (
{children} <div className={styles.actions} onClick={e => e.stopPropagation()}>
</div> {children}
</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,33 +349,35 @@ export const ExplorerTreeNode = ({
</div> </div>
{postfix} {postfix}
<div {mobile ? null : (
className={styles.postfix} <div
onClick={e => { className={styles.postfix}
// prevent jump to page onClick={e => {
e.stopPropagation(); // prevent jump to page
e.preventDefault(); e.stopPropagation();
}} e.preventDefault();
> }}
{inlineOperations.map(({ view }, index) => ( >
<Fragment key={index}>{view}</Fragment> {inlineOperations.map(({ view }, index) => (
))} <Fragment key={index}>{view}</Fragment>
{menuOperations.length > 0 && ( ))}
<Menu {menuOperations.length > 0 && (
items={menuOperations.map(({ view }, index) => ( <Menu
<Fragment key={index}>{view}</Fragment> items={menuOperations.map(({ view }, index) => (
))} <Fragment key={index}>{view}</Fragment>
> ))}
<IconButton
size="16"
data-testid="explorer-tree-node-operation-button"
style={{ marginLeft: 4 }}
> >
<MoreHorizontalIcon /> <IconButton
</IconButton> size="16"
</Menu> data-testid="explorer-tree-node-operation-button"
)} style={{ marginLeft: 4 }}
</div> >
<MoreHorizontalIcon />
</IconButton>
</Menu>
)}
</div>
)}
</div> </div>
{renameable && ( {renameable && (