Skip to content

Commit

Permalink
feat(DragDropSort): update drag button usage v5 (#10357)
Browse files Browse the repository at this point in the history
  • Loading branch information
kmcfaul authored Jun 3, 2024
1 parent 4cb0f76 commit 871ba54
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,12 @@ export const DragDropSort: React.FunctionComponent<DragDropSortProps> = ({
break;
default:
content = (
<Draggable useDragButton={variant === 'defaultWithHandle'} key={item.id} id={item.id} {...item.props}>
<Draggable
useDragButton={variant === 'defaultWithHandle' || variant === 'default'}
key={item.id}
id={item.id}
{...item.props}
>
{item.content}
</Draggable>
);
Expand Down Expand Up @@ -157,7 +162,12 @@ export const DragDropSort: React.FunctionComponent<DragDropSortProps> = ({
);
default:
return (
<Draggable useDragButton={variant === 'defaultWithHandle'} key={item.id} id={item.id} {...item.props}>
<Draggable
useDragButton={variant === 'defaultWithHandle' || variant === 'default'}
key={item.id}
id={item.id}
{...item.props}
>
{item.content}
</Draggable>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,99 @@ exports[`renders some divs 1`] = `
>
<div>
<div
aria-describedby="DndDescribedBy-0"
aria-disabled="false"
aria-roledescription="sortable"
class=""
role="button"
tabindex="0"
>
<button
aria-describedby="DndDescribedBy-0"
aria-disabled="false"
aria-label="Drag button"
aria-roledescription="sortable"
class="pf-v5-c-button pf-m-plain"
role="button"
tabindex="0"
>
<span
class="pf-v5-c-data-list__item-draggable-icon"
>
<svg
aria-hidden="true"
class="pf-v5-svg"
fill="currentColor"
height="1em"
role="img"
viewBox="0 0 320 512"
width="1em"
>
<path
d="M96 32H32C14.33 32 0 46.33 0 64v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32V64c0-17.67-14.33-32-32-32zm0 160H32c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32zm0 160H32c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32zM288 32h-64c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32V64c0-17.67-14.33-32-32-32zm0 160h-64c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32zm0 160h-64c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32z"
/>
</svg>
</span>
</button>
one
</div>
<div
aria-describedby="DndDescribedBy-0"
aria-disabled="false"
aria-roledescription="sortable"
class=""
role="button"
tabindex="0"
>
<button
aria-describedby="DndDescribedBy-0"
aria-disabled="false"
aria-label="Drag button"
aria-roledescription="sortable"
class="pf-v5-c-button pf-m-plain"
role="button"
tabindex="0"
>
<span
class="pf-v5-c-data-list__item-draggable-icon"
>
<svg
aria-hidden="true"
class="pf-v5-svg"
fill="currentColor"
height="1em"
role="img"
viewBox="0 0 320 512"
width="1em"
>
<path
d="M96 32H32C14.33 32 0 46.33 0 64v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32V64c0-17.67-14.33-32-32-32zm0 160H32c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32zm0 160H32c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32zM288 32h-64c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32V64c0-17.67-14.33-32-32-32zm0 160h-64c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32zm0 160h-64c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32z"
/>
</svg>
</span>
</button>
two
</div>
<div
aria-describedby="DndDescribedBy-0"
aria-disabled="false"
aria-roledescription="sortable"
class=""
role="button"
tabindex="0"
>
<button
aria-describedby="DndDescribedBy-0"
aria-disabled="false"
aria-label="Drag button"
aria-roledescription="sortable"
class="pf-v5-c-button pf-m-plain"
role="button"
tabindex="0"
>
<span
class="pf-v5-c-data-list__item-draggable-icon"
>
<svg
aria-hidden="true"
class="pf-v5-svg"
fill="currentColor"
height="1em"
role="img"
viewBox="0 0 320 512"
width="1em"
>
<path
d="M96 32H32C14.33 32 0 46.33 0 64v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32V64c0-17.67-14.33-32-32-32zm0 160H32c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32zm0 160H32c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32zM288 32h-64c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32V64c0-17.67-14.33-32-32-32zm0 160h-64c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32zm0 160h-64c-17.67 0-32 14.33-32 32v64c0 17.67 14.33 32 32 32h64c17.67 0 32-14.33 32-32v-64c0-17.67-14.33-32-32-32z"
/>
</svg>
</span>
</button>
three
</div>
</div>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export const BasicSortingWithDragButton: React.FunctionComponent = () => {
return (
<DragDropSort
items={items}
variant="defaultWithHandle"
onDrop={(_, newItems) => {
setItems(newItems);
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ import { DragDropSort } from '@patternfly/react-drag-drop';

### Basic drag and drop sorting

```ts file="./BasicSorting.tsx"

```

### Basic drag and drop sorting with drag button

```ts file="./BasicSortingWithDragButton.tsx"

```

0 comments on commit 871ba54

Please sign in to comment.