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

website: Drag handles for ranking items #230

Merged
merged 4 commits into from
Jan 1, 2023

Conversation

othrayte
Copy link
Collaborator

@othrayte othrayte commented Jan 1, 2023

Adds drag handles, to the rank prompts and replies pages of the website.
Closes #223

Removed the dot points that were appearing next to each item. Restrict ranking items to vertical motion to avoid breaking the webpage layout; there is an even better option to restrict to the window but that didn't seem to work on mobile (firefox) were the issue looks the most unprofessional.

Also enabled the keyboard sensor so that the items can be moved without a mouse. To use select one of the drag handles with TAB or the mouse to give it focus, press ENTER or SPACE to start moving the item and use the arrow keys (up or down) to reorder the items, press ENTER or SPACE again when done, ESCAPE cancels the action. There is a full description at https://docs.dndkit.com/guides/accessibility#keyboard-shortcuts which also mentions we might want to customise the screen reader prompt.

image

…lear they can be dragged.

The formatting changes to the SortableItem also had the side-effect of removing the dot points.
…the webpage layout.

When the items are drag-able outside the page boundary the viewport leaves the page boundary. This looks particularly unprofessionally on mobile. There is also another option to restrict to the page boundaries (restrictToWindowEdges) which might be better but it doesn't appear to work on mobile (firefox); the issue is that the items get stuck slightly off to the left edge of the viewport and can't be moved horizontally at all (even without restrictToVerticalAxis).
sortableKeyboardCoordinates,
verticalListSortingStrategy,
} from "@dnd-kit/sortable";
import { restrictToVerticalAxis } from "@dnd-kit/modifiers";
Copy link
Collaborator

Choose a reason for hiding this comment

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

small nit, could you move this import up above sortable so it's in order?

Copy link
Collaborator Author

@othrayte othrayte Jan 1, 2023

Choose a reason for hiding this comment

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

Sure, just to confirm external imports should be alphabetically by @scope / unscoped name, then by scoped package name? so:

  • a
  • @b/a
  • @b/e
  • c
  • c-foo

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think with the new eslint change that goes in @ is always first. So it'd be

@b/a
@b/e
a
c
c-foo

@othrayte othrayte requested a review from fozziethebeat January 1, 2023 06:36
@fozziethebeat fozziethebeat merged commit ef0a287 into LAION-AI:main Jan 1, 2023
@othrayte othrayte deleted the drag-handles branch January 1, 2023 07:54
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.

Add drag handles for rankable (sortable) items
2 participants