Desktop: Fixes #7776: Drag-dropping notes to top or bottom, in custom sort, is finicky (#7777)

pull/7844/head
Tao Klerks 2023-02-26 16:40:13 +01:00 committed by GitHub
parent da11476fd7
commit 9c080ec631
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 4 deletions

View File

@ -8,6 +8,7 @@ interface Props {
onKeyDown?: Function;
itemRenderer: Function;
className?: string;
onNoteDrop?: Function;
}
interface State {
@ -29,6 +30,7 @@ class ItemList extends React.Component<Props, State> {
this.onScroll = this.onScroll.bind(this);
this.onKeyDown = this.onKeyDown.bind(this);
this.onDrop = this.onDrop.bind(this);
}
visibleItemCount(props: Props = undefined) {
@ -76,6 +78,10 @@ class ItemList extends React.Component<Props, State> {
if (this.props.onKeyDown) this.props.onKeyDown(event);
}
onDrop(event: any) {
if (this.props.onNoteDrop) this.props.onNoteDrop(event);
}
makeItemIndexVisible(itemIndex: number) {
const top = Math.min(this.props.items.length - 1, this.state.topItemIndex);
const bottom = Math.max(0, this.state.bottomItemIndex);
@ -141,7 +147,7 @@ class ItemList extends React.Component<Props, State> {
if (this.props.className) classes.push(this.props.className);
return (
<div ref={this.listRef} className={classes.join(' ')} style={style} onScroll={this.onScroll} onKeyDown={this.onKeyDown}>
<div ref={this.listRef} className={classes.join(' ')} style={style} onScroll={this.onScroll} onKeyDown={this.onKeyDown} onDrop={this.onDrop}>
{itemComps}
</div>
);

View File

@ -275,7 +275,6 @@ const NoteListComponent = (props: Props) => {
onCheckboxClick={noteItem_checkboxClick}
onDragStart={noteItem_dragStart}
onNoteDragOver={noteItem_noteDragOver}
onNoteDrop={noteItem_noteDrop}
onTitleClick={noteItem_titleClick}
onContextMenu={itemContextMenu}
/>;
@ -526,6 +525,7 @@ const NoteListComponent = (props: Props) => {
style={props.size}
itemRenderer={renderItem}
onKeyDown={onKeyDown}
onNoteDrop={noteItem_noteDrop}
/>
);
};

View File

@ -56,7 +56,6 @@ interface NoteListItemProps {
onCheckboxClick: any;
onDragStart: any;
onNoteDragOver: any;
onNoteDrop: any;
onTitleClick: any;
onContextMenu(event: React.MouseEvent<HTMLAnchorElement, MouseEvent>): void;
}
@ -175,7 +174,6 @@ function NoteListItem(props: NoteListItemProps, ref: any) {
<StyledRoot
className={classNames}
onDragOver={props.onNoteDragOver}
onDrop={props.onNoteDrop}
width={props.width}
height={props.height}
isProvisional={props.isProvisional}