-
-
Notifications
You must be signed in to change notification settings - Fork 200
feat(ui): Implement drag-and-drop to reorder accounts Description #5279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
CI linter is unhappy about missing const and one unused variable, should be an easy fix. |
() => async () => { | ||
try { | ||
// Use getAccountsOrder instead of getAllAccountIds to get the proper ordering | ||
const accounts = await (BackendRemote.rpc as any).getAccountsOrder() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is outdated, need to use getAllAccountIds now.
const accountsListRef = useRef<HTMLDivElement>(null) | ||
const { openDialog } = useDialog() | ||
|
||
const accountsFetch = useRpcFetch(BackendRemote.rpc.getAllAccountIds, []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a reason to not use useRpcFetch
anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like the merger of main into this branch simply reverted all the recent changes from main
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that is true. :(
I will pull it again and do the changes again
I also noticed that if I drag the icon not on another icon, but precisely in-between, then nothing is changed. Moving only works by dragging on another icon, and depending on whether you point at the top or bottom half you get different position. |
|
Telegram looks good. |
Description
What does this PR do?
This pull request introduces the user-facing functionality for reordering accounts in the
AccountListSidebar
. Users can now drag and drop their account icons to set a custom display order. This change builds upon the backend functionality introduced in the core library and resolves a key part of issue #3671.How It Works
This implementation uses native HTML drag-and-drop events within the React component to provide a smooth and responsive user experience.
Fetching the Initial Order:
getAccountsOrder()
RPC method (instead ofgetAllAccountIds()
) to fetch the list of accounts in their correct, user-defined order on initial load.Drag-and-Drop Logic (
AccountListSidebar.tsx
):draggedAccountId
,dropIndicator
) are used to track the item being dragged and the potential drop location.onDragStart
: Captures the ID of the account being dragged.onDragOver
: Prevents the default browser behavior and calculates whether the drop target is in the top or bottom half of the element being hovered over. This determines where the drop indicator line is shown.onDrop
:accounts
state is updated immediately to give the user instant visual feedback.setAccountsOrder()
RPC method to persist the new order in theaccounts.toml
file.refresh()
.onDragEnd
&onDragLeave
: Clean up the state to remove visual indicators.Visual Feedback (
styles.module.scss
):.dragging
class is applied to the account item being dragged, reducing its opacity and slightly scaling it down..dragOverTop
and.dragOverBottom
classes add a clear visual line (using a::before
pseudo-element) above or below the target item to show the user exactly where the account will be dropped.Author's Notes & Context
core
implementation. LINK TO PRaccounts.toml
. This approach ensures the order is persisted correctly across sessions. It avoids usinglocalStorage
for a more robust solution, as was discussed.window.__updateAccountListSidebar
hack is still present but is unrelated to this change and will be addressed separately as noted in the issue.