Skip to content
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

Add buttons to reorder split panes #3984

Merged
merged 4 commits into from
Jun 2, 2023
Merged

Add buttons to reorder split panes #3984

merged 4 commits into from
Jun 2, 2023

Conversation

dymani
Copy link
Contributor

@dymani dymani commented May 29, 2023

Background

I use the split-pane function quite often to view other reference/literature notes when doing my writing. Sometimes I need to compare difference versions of my work, and I find it quite clumsy to swap the notes in the two panes, i.e. focus into the left pane, jump to another note, focus into the right pane, and then jump to another note.

It would be nice if we can somehow reorder the panes to better organize the notes. The reordering/swapping buttons would also allow "closing the left pane" without using the Jump to Note function, that would become a simple swap followed by closing the right pane.

Proposed funtion

Introduce "Move left" and "Move right" buttons next to "Create new split" and "Close this pane" buttons for users to reorder split panes. When split panes are used, these buttons will appear given that the moving direction is valid in relation to other panes on the screen.

2023-05-30_03-18-15

2023-05-30_03-18-27

In case there are more than two panes, both buttons will be shown in the middle panes. Also, when one of the panes involved in the move operation is empty, it has the same effect as copying the non-empty pane to the empty one.

2023-05-30_03-22-02

2023-05-30_03-22-06

In this implementation, the note contexts will switch directly to their new note paths. A small catch is that the scrolling position in the panes will not be preserved. I think it might be possible to utilize the noteContextReorder event, but I found it quite complicated since we also need to update the main context ID of all the subcontexts before refreshing the UI. Anyway, I think the current proof of concept should be good enough for most use cases.

@dymani
Copy link
Contributor Author

dymani commented May 30, 2023

I have changed the mechanism to utilize the noteContextReorder event with proper handling of context and tab changes. This has a better performance and the swapping now feels snappier.

2023-05-31_02-06-17

2023-05-31_02-05-05

As shown in the first GIF, the scrolling position can be preserved when the Formatting examples pane is moved to the left. For some reasons, a note will scroll back to the top when it is moved to the right. So this is still a minor FIXME.

This even enables a more-intuitive swapping when new tab is involved, instead of cloning the existing pane to the empty one.

2023-05-31_02-06-56

When testing the swapping of new tabs, I discovered an existing bug in master (0.60.1-beta) that breaks the tab row if the main context is an empty note upon refreshing the page. It is described in #3985.

@zadam
Copy link
Owner

zadam commented May 30, 2023

Thanks, that looks useful! I'll take a closer look tomorrow.

Copy link
Owner

@zadam zadam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good with some minor comments.

@dymani
Copy link
Contributor Author

dymani commented Jun 2, 2023

I have simplified the logic by passing the new and old main contexts IDs instead of passing arrays around, since we can assume there will be at most 1 main context change per reorder event.

@zadam zadam merged commit af67cf6 into zadam:master Jun 2, 2023
@zadam
Copy link
Owner

zadam commented Jun 2, 2023

Thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants