You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
return`Grabbed kanban column "${activeValue}". Current position is ${columnIndex+1} of ${Object.keys(value).length}. Use arrow keys to move, space to drop.`;
514
+
}
515
+
516
+
constcontainer=getContainer(active.id);
517
+
if(!container)return;
518
+
constcontainerItems=value[container];
519
+
if(!containerItems?.length)return;
520
+
constitemIndex=containerItems.findIndex(
521
+
(item)=>getItemValue(item)===active.id,
522
+
);
523
+
return`Grabbed kanban item "${activeValue}". Current position is ${itemIndex+1} of ${containerItems.length} in column "${container}". Use arrow keys to move, space to drop.`;
524
+
},
525
+
onDragOver({ active, over }){
526
+
if(!over){
527
+
return"Item is no longer over a droppable area. Press escape to cancel.";
@@ -176,6 +177,17 @@ function Sortable<T>(props: SortableProps<T>) {
176
177
[value,onValueChange,onMove,getItemValue],
177
178
);
178
179
180
+
constscreenReaderInstructions=React.useMemo(
181
+
()=>({
182
+
draggable: `
183
+
To pick up a sortable item, press space or enter.
184
+
While dragging, use the ${orientation==="vertical" ? "up and down" : orientation==="horizontal" ? "left and right" : "arrow"} keys to move the item.
185
+
Press space or enter again to drop the item in its new position, or press escape to cancel.
186
+
`,
187
+
}),
188
+
[orientation],
189
+
);
190
+
179
191
constcontextValue=React.useMemo(
180
192
()=>({
181
193
id,
@@ -218,34 +230,48 @@ function Sortable<T>(props: SortableProps<T>) {
218
230
setActiveId(null),
219
231
)}
220
232
accessibility={{
221
-
...props.accessibility,
222
233
announcements: {
223
234
onDragStart({ active }){
224
-
return`Picked up sortable item ${active.id}. Use arrow keys to move, space to drop.`;
235
+
constactiveValue=active.id.toString();
236
+
return`Grabbed sortable item "${activeValue}". Current position is ${active.data.current?.sortable.index+1} of ${value.length}. Use arrow keys to move, space to drop.`;
225
237
},
226
238
onDragOver({ active, over }){
227
239
if(over){
228
-
return`Sortable item ${active.id} was moved over position ${over.id}.`;
0 commit comments