Skip to content

Commit 8071ba6

Browse files
johannes-weberJohannes Weber
andauthored
revert: "feat: Add UAP directional controls and tooltips to drag/resize handles (#356)" (#360)
Co-authored-by: Johannes Weber <[email protected]>
1 parent aa1f984 commit 8071ba6

File tree

24 files changed

+273
-1436
lines changed

24 files changed

+273
-1436
lines changed

pages/shared/i18n.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ export const boardItemI18nStrings: BoardItemProps.I18nStrings = {
6161
resizeHandleAriaLabel: "Resize handle",
6262
resizeHandleAriaDescription:
6363
"Use Space or Enter to activate resize, arrow keys to move, Space or Enter to submit, or Escape to discard. Be sure to temporarily disable any screen reader navigation feature that may interfere with the functionality of the arrow keys.",
64-
dragHandleTooltipText: "Drag or select to move",
65-
resizeHandleTooltipText: "Drag or select to resize",
6664
};
6765

6866
export const itemsPaletteI18nStrings: ItemsPaletteProps.I18nStrings<ItemData> = {

src/__tests__/__snapshots__/documenter.test.ts.snap

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,7 @@ ARIA labels:
201201
* \`dragHandleAriaLabel\` (string) - the ARIA label for the drag handle.
202202
* \`dragHandleAriaDescription\` (string, optional) - the ARIA description for the drag handle.
203203
* \`resizeHandleAriaLabel\` (string) - the ARIA label for the resize handle.
204-
* \`resizeHandleAriaDescription\` (string, optional) - the ARIA description for the resize handle.
205-
* \`dragHandleTooltipText\` (string, optional) - the ARIA description for the resize handle.
206-
* \`resizeHandleTooltipText\` (string, optional) - the Text for the resize handle Tooltip.",
204+
* \`resizeHandleAriaDescription\` (string, optional) - the ARIA description for the resize handle.",
207205
"inlineType": {
208206
"name": "BoardItemProps.I18nStrings",
209207
"properties": [
@@ -217,11 +215,6 @@ ARIA labels:
217215
"optional": false,
218216
"type": "string",
219217
},
220-
{
221-
"name": "dragHandleTooltipText",
222-
"optional": true,
223-
"type": "string",
224-
},
225218
{
226219
"name": "resizeHandleAriaDescription",
227220
"optional": true,
@@ -232,11 +225,6 @@ ARIA labels:
232225
"optional": false,
233226
"type": "string",
234227
},
235-
{
236-
"name": "resizeHandleTooltipText",
237-
"optional": true,
238-
"type": "string",
239-
},
240228
],
241229
"type": "object",
242230
},

src/board-item/__tests__/board-item-wrapper.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,16 @@ export function ItemContextWrapper({ children }: { children: ReactNode }) {
99
<ItemContext.Provider
1010
value={{
1111
isActive: false,
12-
isHidden: false,
1312
dragHandle: {
1413
ref: { current: null },
1514
onPointerDown: () => {},
1615
onKeyDown: () => {},
17-
activeState: null,
18-
onDirectionClick: () => {},
16+
isActive: false,
1917
},
2018
resizeHandle: {
2119
onPointerDown: () => {},
2220
onKeyDown: () => {},
23-
activeState: null,
24-
onDirectionClick: () => {},
21+
isActive: false,
2522
},
2623
}}
2724
>

src/board-item/__tests__/board-item.test.tsx

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
import { ReactElement } from "react";
5-
import { cleanup, fireEvent, render as libRender } from "@testing-library/react";
5+
import { cleanup, render as libRender } from "@testing-library/react";
66
import { afterEach, describe, expect, test } from "vitest";
77

88
import Button from "@cloudscape-design/components/button";
99
import Container from "@cloudscape-design/components/container";
1010
import ExpandableSection from "@cloudscape-design/components/expandable-section";
1111
import Header from "@cloudscape-design/components/header";
12-
import DragHandleWrapper from "@cloudscape-design/components/test-utils/dom/internal/drag-handle";
13-
import TooltipWrapper from "@cloudscape-design/components/test-utils/dom/internal/tooltip";
1412

1513
import "@cloudscape-design/components/test-utils/dom";
1614
import BoardItem from "../../../lib/components/board-item";
@@ -20,8 +18,6 @@ import { ItemContextWrapper } from "./board-item-wrapper";
2018
const i18nStrings = {
2119
dragHandleAriaLabel: "Drag handle",
2220
resizeHandleAriaLabel: "Resize handle",
23-
dragHandleTooltipText: "Drag or select to move",
24-
resizeHandleTooltipText: "Drag or select to resize",
2521
};
2622

2723
function render(jsx: ReactElement) {
@@ -65,72 +61,4 @@ describe("WidgetContainer", () => {
6561
expect(getByLabelText("Drag handle")).toBeDefined();
6662
expect(getByLabelText("Resize handle")).toBeDefined();
6763
});
68-
69-
test("renders drag handle tooltip text if provided", () => {
70-
render(<BoardItem i18nStrings={i18nStrings} />);
71-
const wrapper = createWrapper();
72-
const dragHandleEl = wrapper.findBoardItem()!.findDragHandle().getElement();
73-
74-
fireEvent(dragHandleEl, new MouseEvent("pointerover", { bubbles: true }));
75-
const tooltipEl = wrapper.findByClassName(TooltipWrapper.rootSelector)!.getElement();
76-
expect(tooltipEl.textContent).toBe("Drag or select to move");
77-
});
78-
79-
test("does not render drag handle tooltip text if not provided", () => {
80-
render(<BoardItem i18nStrings={{ ...i18nStrings, dragHandleTooltipText: undefined }} />);
81-
const wrapper = createWrapper();
82-
const dragHandleEl = wrapper.findBoardItem()!.findDragHandle().getElement();
83-
84-
fireEvent(dragHandleEl, new MouseEvent("pointerover", { bubbles: true }));
85-
expect(wrapper.findByClassName(TooltipWrapper.rootSelector)).toBeNull();
86-
});
87-
88-
test("renders drag handle UAP actions on handle click", () => {
89-
render(<BoardItem i18nStrings={i18nStrings} />);
90-
const dragHandleEl = createWrapper().findBoardItem()!.findDragHandle()!.getElement();
91-
92-
fireEvent(dragHandleEl, new MouseEvent("pointerdown", { bubbles: true }));
93-
fireEvent(dragHandleEl, new MouseEvent("pointerup", { bubbles: true }));
94-
95-
const dragHandleWrapper = new DragHandleWrapper(document.body);
96-
expect(dragHandleWrapper.findAllVisibleDirectionButtons()).toHaveLength(4);
97-
expect(dragHandleWrapper.findVisibleDirectionButtonBlockStart()).toBeDefined();
98-
expect(dragHandleWrapper.findVisibleDirectionButtonBlockEnd()).toBeDefined();
99-
expect(dragHandleWrapper.findVisibleDirectionButtonInlineStart()).toBeDefined();
100-
expect(dragHandleWrapper.findVisibleDirectionButtonInlineEnd()).toBeDefined();
101-
});
102-
103-
test("renders resize handle tooltip text", () => {
104-
render(<BoardItem i18nStrings={i18nStrings} />);
105-
const wrapper = createWrapper();
106-
const resizeHandleEl = wrapper.findBoardItem()!.findResizeHandle()!.getElement();
107-
108-
fireEvent(resizeHandleEl, new MouseEvent("pointerover", { bubbles: true }));
109-
const tooltipEl = wrapper.findByClassName(TooltipWrapper.rootSelector)!.getElement();
110-
expect(tooltipEl.textContent).toBe("Drag or select to resize");
111-
});
112-
113-
test("does not render resize handle tooltip text if not provided", () => {
114-
render(<BoardItem i18nStrings={{ ...i18nStrings, resizeHandleTooltipText: undefined }} />);
115-
const wrapper = createWrapper();
116-
const resizeHandleEl = wrapper.findBoardItem()!.findResizeHandle()!.getElement();
117-
118-
fireEvent(resizeHandleEl, new MouseEvent("pointerover", { bubbles: true }));
119-
expect(wrapper.findByClassName(TooltipWrapper.rootSelector)).toBeNull();
120-
});
121-
122-
test("renders resize handle UAP actions on handle click", () => {
123-
render(<BoardItem i18nStrings={i18nStrings} />);
124-
const resizeHandleEl = createWrapper().findBoardItem()!.findResizeHandle()!.getElement();
125-
126-
fireEvent(resizeHandleEl, new MouseEvent("pointerdown", { bubbles: true }));
127-
fireEvent(resizeHandleEl, new MouseEvent("pointerup", { bubbles: true }));
128-
129-
const dragHandleWrapper = new DragHandleWrapper(document.body);
130-
expect(dragHandleWrapper.findAllVisibleDirectionButtons()).toHaveLength(4);
131-
expect(dragHandleWrapper.findVisibleDirectionButtonBlockStart()).toBeDefined();
132-
expect(dragHandleWrapper.findVisibleDirectionButtonBlockEnd()).toBeDefined();
133-
expect(dragHandleWrapper.findVisibleDirectionButtonInlineStart()).toBeDefined();
134-
expect(dragHandleWrapper.findVisibleDirectionButtonInlineEnd()).toBeDefined();
135-
});
13664
});

src/board-item/interfaces.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ export interface BoardItemProps {
3737
* * `dragHandleAriaDescription` (string, optional) - the ARIA description for the drag handle.
3838
* * `resizeHandleAriaLabel` (string) - the ARIA label for the resize handle.
3939
* * `resizeHandleAriaDescription` (string, optional) - the ARIA description for the resize handle.
40-
* * `dragHandleTooltipText` (string, optional) - the ARIA description for the resize handle.
41-
* * `resizeHandleTooltipText` (string, optional) - the Text for the resize handle Tooltip.
4240
*/
4341
i18nStrings: BoardItemProps.I18nStrings;
4442
}
@@ -49,7 +47,5 @@ export namespace BoardItemProps {
4947
dragHandleAriaDescription?: string;
5048
resizeHandleAriaLabel: string;
5149
resizeHandleAriaDescription?: string;
52-
dragHandleTooltipText?: string;
53-
resizeHandleTooltipText?: string;
5450
}
5551
}

src/board-item/internal.tsx

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ import { useId } from "react";
44
import clsx from "clsx";
55

66
import Container from "@cloudscape-design/components/container";
7-
import { InternalDragHandleProps } from "@cloudscape-design/components/internal/do-not-use/drag-handle";
87

98
import { getDataAttributes } from "../internal/base-component/get-data-attributes";
109
import { InternalBaseComponentProps } from "../internal/base-component/use-base-component";
1110
import DragHandle from "../internal/drag-handle";
12-
import { Direction } from "../internal/interfaces";
1311
import { useItemContext } from "../internal/item-container";
1412
import ResizeHandle from "../internal/resize-handle";
1513
import ScreenreaderOnly from "../internal/screenreader-only";
@@ -18,16 +16,6 @@ import type { BoardItemProps } from "./interfaces";
1816

1917
import styles from "./styles.css.js";
2018

21-
const mapToKeyboardDirection = (direction: InternalDragHandleProps.Direction) => {
22-
const directionMap: Record<InternalDragHandleProps.Direction, Direction> = {
23-
"inline-start": "left",
24-
"inline-end": "right",
25-
"block-start": "up",
26-
"block-end": "down",
27-
};
28-
return directionMap[direction];
29-
};
30-
3119
export function InternalBoardItem({
3220
children,
3321
header,
@@ -38,20 +26,14 @@ export function InternalBoardItem({
3826
__internalRootRef,
3927
...rest
4028
}: BoardItemProps & InternalBaseComponentProps) {
41-
const { dragHandle, resizeHandle, isActive, isHidden } = useItemContext();
29+
const { dragHandle, resizeHandle, isActive } = useItemContext();
4230

4331
const dragHandleAriaLabelledBy = useId();
4432
const dragHandleAriaDescribedBy = useId();
4533

4634
const resizeHandleAriaLabelledBy = useId();
4735
const resizeHandleAriaDescribedBy = useId();
4836

49-
// A board item is hidden while moving a board item from the palette to the board via keyboard or UAP.
50-
// The wrapping container is set to invisible, so we don't need to render anything.
51-
if (isHidden) {
52-
return null;
53-
}
54-
5537
return (
5638
<div ref={__internalRootRef} className={styles.root} {...getDataAttributes(rest)}>
5739
<Container
@@ -66,10 +48,7 @@ export function InternalBoardItem({
6648
ariaDescribedBy={dragHandleAriaDescribedBy}
6749
onPointerDown={dragHandle.onPointerDown}
6850
onKeyDown={dragHandle.onKeyDown}
69-
activeState={dragHandle.activeState}
70-
initialShowButtons={dragHandle.initialShowButtons}
71-
onDirectionClick={(direction) => dragHandle.onDirectionClick(mapToKeyboardDirection(direction), "drag")}
72-
dragHandleTooltipText={i18nStrings.dragHandleTooltipText}
51+
isActive={dragHandle.isActive}
7352
/>
7453
}
7554
settings={settings}
@@ -90,11 +69,7 @@ export function InternalBoardItem({
9069
ariaDescribedBy={resizeHandleAriaDescribedBy}
9170
onPointerDown={resizeHandle.onPointerDown}
9271
onKeyDown={resizeHandle.onKeyDown}
93-
activeState={resizeHandle.activeState}
94-
onDirectionClick={(direction) => {
95-
resizeHandle.onDirectionClick(mapToKeyboardDirection(direction), "resize");
96-
}}
97-
resizeHandleTooltipText={i18nStrings.resizeHandleTooltipText}
72+
isActive={resizeHandle.isActive}
9873
/>
9974
</div>
10075
)}

src/board-item/styles.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
.container-override.active {
1414
box-shadow: cs.$shadow-container-active;
1515

16-
@include shared.focus-highlight(0px, cs.$border-radius-container);
16+
:global([data-awsui-focus-visible]) & {
17+
@include shared.focus-highlight(0px, cs.$border-radius-container);
18+
}
1719
}
1820

1921
.header {

0 commit comments

Comments
 (0)