Skip to content

Bug - [DragDropSort / DragButton] - aria-label is not customizable and not translatable #12416

Closed

Description

@logonoff

Describe the problem

Two issues in @patternfly/react-drag-drop:

  1. The DragButton component has a hardcoded English aria-label default of "Drag button" that cannot be customized by consumers of DragDropSort.

    DragButton accepts an aria-label prop (source), but Draggable only passes dnd-kit's {...attributes} and {...listeners} to it — not consumer-provided props. And item.props in DraggableObject is spread onto the Draggable wrapper <div>, not onto DragButton.

    This means there is no way for consumers using DragDropSort to provide a translated aria-label for the drag handle, which is an i18n/a11y gap.

  2. DragDropContainer renders the literal text "0" as the drag overlay when a draggable item has a falsy numeric id (e.g. 0).

How do you reproduce the problem?

import { DragDropSort } from '@patternfly/react-drag-drop';

const items = [
  { id: 0, content: 'First item' },
  { id: 1, content: 'Second item' },
];

<DragDropSort items={items} onDrop={(_, newItems) => setItems(newItems)} />
  1. Inspect the rendered drag handle button — it always has aria-label="Drag button" regardless of locale.

  2. Drag the first item (id 0). The drag overlay renders the text "0" instead of the item content. This is because getDragOverlay has if (!activeId) return which is true for 0, and the overlay JSX uses activeId && getDragOverlay() which short-circuits to 0 — React renders this as the text "0".

Expected behavior

  1. Consumers should be able to provide a custom/translated aria-label for the DragButton, either via:

    • A prop on DraggableObject (e.g. item.props.dragButtonAriaLabel)
    • Forwarding relevant props from item.props to DragButton
  2. Falsy numeric ids (e.g. 0) should work correctly. The checks should use activeId != null instead of !activeId / activeId &&.

Is this issue blocking you?

Not blocking. Workaround for issue 1: not possible without forking the component. We currently accept the English-only label. Workaround for issue 2: use string ids.

Screenshots

N/A

What is your environment?

  • @patternfly/react-drag-drop: 6.x (pre-release)

  • React 18

What is your product and what release date are you targeting?

OpenShift Console (no hard deadline for this specific issue)

Any other information?

N/A


Jira Issue: PF-4132

Activity

  1. coderabbitai commented on May 7, 2026

    @coderabbitai
    🔗 Related PRs

    #12140 - feat(TreeView): add support for disabled TreeViewListItems [merged]
    #12192 - fix(Label): render add variant labels as buttons [merged]
    #12240 - fix(react-drag-drop): support dynamic root element IDs in DragDropCon… [merged]
    #12306 - fix: Updated drag and drop to use the correct glass theme. [merged]
    #12388 - feat(Pagination): added dynamic sticky and plain [merged]


    📝 Issue Planner

    Check the box below or use the @coderabbitai plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.

    • Create Plan

    🧪 Issue enrichment is currently in open beta.

    You can configure auto-planning by selecting labels in the issue_enrichment configuration.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions