mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-21 15:36:50 -05:00
Compare commits
1 Commits
claude/pub
...
non-chrome
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e6ccc756c3 |
@@ -2,6 +2,8 @@ import React, {
|
|||||||
type ComponentPropsWithoutRef,
|
type ComponentPropsWithoutRef,
|
||||||
type CSSProperties,
|
type CSSProperties,
|
||||||
useCallback,
|
useCallback,
|
||||||
|
useEffect,
|
||||||
|
useRef,
|
||||||
} from 'react';
|
} from 'react';
|
||||||
import { type DragItem } from 'react-aria';
|
import { type DragItem } from 'react-aria';
|
||||||
import {
|
import {
|
||||||
@@ -134,6 +136,24 @@ function AccountListItem({
|
|||||||
...props
|
...props
|
||||||
}: AccountListItemProps) {
|
}: AccountListItemProps) {
|
||||||
const { value: account } = props;
|
const { value: account } = props;
|
||||||
|
const buttonRef = useRef<HTMLButtonElement | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const currentButtonRef = buttonRef.current;
|
||||||
|
if (!currentButtonRef) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
currentButtonRef.draggable = true;
|
||||||
|
|
||||||
|
function onDragStart(e: DragEvent) {
|
||||||
|
e.dataTransfer.setData('text/plain', account.id);
|
||||||
|
};
|
||||||
|
currentButtonRef.addEventListener('dragstart', onDragStart);
|
||||||
|
return () => {
|
||||||
|
currentButtonRef.removeEventListener('dragstart', onDragStart)
|
||||||
|
}
|
||||||
|
}, [account]);
|
||||||
|
|
||||||
if (!account) {
|
if (!account) {
|
||||||
return null;
|
return null;
|
||||||
@@ -143,6 +163,7 @@ function AccountListItem({
|
|||||||
<ListBoxItem textValue={account.name} {...props}>
|
<ListBoxItem textValue={account.name} {...props}>
|
||||||
{itemProps => (
|
{itemProps => (
|
||||||
<Button
|
<Button
|
||||||
|
ref={buttonRef}
|
||||||
{...itemProps}
|
{...itemProps}
|
||||||
style={{
|
style={{
|
||||||
width: '100%',
|
width: '100%',
|
||||||
|
|||||||
Reference in New Issue
Block a user