Add Sortable Component (Based on sortable.js)#209
Conversation
Merge changes from upstream
…layout, and comprehensive demo - Extract BbSortable code to BbSortable.razor.cs (partial class) - Add @namespace BlazorBlueprint.Components to BbSortable.razor - Rename T→TItem and SortableItemTemplate→ItemTemplate - Fix ForceFallback bug (param was defined but never passed to JS init()) - Add OnAdd EventCallback + OnAddJS [JSInvokable] for clean cross-list tracking - Add WAI-ARIA: role=list, aria-label, sr-only live region announcements - Add Layout (SortableLayout.List/Grid), Class, AriaLabel, AdditionalAttributes params - Add SortableLayout enum (List, Grid) - Update sortable.js: add onAdd handler, forceFallback now correctly wired from .NET - Create SortableDemo.razor: basic list, handle, multiple lists, grid, kanban - Create CodeExamples/Components/Sortable/{basic,handle,multiple-lists,grid,kanban}.txt - Add Sortable to DemoSidebar.razor navigation (between Spinner and Split Button) - Add Sortable card to Pages/Components/Index.razor - Update API surface baseline to include BbSortable and SortableLayout Co-authored-by: russkyc <32549126+russkyc@users.noreply.github.com>
Co-authored-by: russkyc <32549126+russkyc@users.noreply.github.com>
…-component-demo feat(sortable): refactor BbSortable, add WAI-ARIA, OnAdd event, grid layout, and comprehensive demo
|
Hi @mathewtaylor , this is a basic implementation of the sortable component. This would cater to both sorting and drag and drop. Here are some previews: compressO-basic-list.mp4compressO-connected-lists.mp4compressO-grid.mp4compressO-kanban.mp4Some quirks:
I don't know if this is the best route because of the quirks, but it could be a starting point. I can't seem to get the quirks ironed out even with copilot. |
|
Hi @russkyc , thanks for putting this together and another contribution to the project! Really cool to see drag-and-drop support coming to the library. I've had a look through the changes and have some feedback before we merge this in.
As usual, if you need my help with any of these, just let me know and I'll be happy to lend a hand. Cheers, |
|
Hi @mathewtaylor , I was preoccupied with a few things so I wasn't able to get back on this. Please take over if possible, it would be very appreciated. |
Complete the Sortable component work from PR #209, addressing all 7 review items from mathewtaylor's feedback: 1. Add destroy() call — JS uses Map-based instance storage with explicit destroy export, called from DisposeAsync with exception guard. 2. Fix pull default — change `pull || true` to `pull ?? true`. 3. Re-init on parameter changes — track previous config values in OnParametersSet, destroy + re-init in OnAfterRenderAsync when changed. 4. Add @key on foreach — wrap each item in `<div @key="item">` for stable Blazor diffing. 5. IList<TItem> — change Items parameter from List<TItem> to IList<TItem>. 6. Global CSS for ghost elements — move sortable-ghost/sortable-fallback styles to blazorblueprint-input.css, delete scoped .razor.css. 7. IdGenerator — replace Guid.NewGuid() defaults with IdGenerator.GenerateId("sortable") / ("sortable-group"). Additionally: - Split into Primitive + Component two-layer architecture. The Primitive (BlazorBlueprint.Primitives.Sortable) owns all JS interop, lifecycle, ARIA, and disposal. The Component is a thin styled wrapper adding SortableLayout enum and Tailwind classes. - Move JS + SortableJS library to Primitives wwwroot. - Use snapshot overlay pattern to prevent visible flash during DOM revert on drop (clone container over real element during revert→ re-render cycle). - Add Primitive demo page, sidebar nav entry, and index card. - Remove wrapper div requirement from demos (automatic via @key wrapper). - Update API surface snapshots for both Primitives and Components.
Description
Adds a new
BbSortable<TItem>component to BlazorBlueprint.Components, providing drag-and-drop sortable lists and grids powered by Sortable.js. Includes a newSortableLayoutenum (List/Grid), JS interop module (wwwroot/js/sortable.js) with a bundled Sortable.js library, component styling, and a full demo page with multiple examples (basic list, drag handle, connected lists, grid layout, and Kanban-style board). Updates the demo components index and sidebar navigation, and updates the Components API surface snapshot baseline.Type of Change
Testing Checklist
Related Issues
None