8000 Fix DataTable expand aria label by jcfilben · Pull Request #7480 · grommet/grommet · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix DataTable expand aria label #7480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/js/components/DataTable/Body.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ const Row = memo(
}
}}
pad={cellProps.pad}
primaryValue={primaryValue}
verticalAlign={verticalAlign}
/>
)}
Expand Down
21 changes: 17 additions & 4 deletions src/js/components/DataTable/ExpanderCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ import { useThemeValue } from '../../utils/useThemeValue';

// ExpanderControl is separated from ExpanderCell to give TableCell a chance
// to set the ThemeContext dark context.
const ExpanderControl = ({ context, expanded, onToggle, pad, ...rest }) => {
const ExpanderControl = ({
context,
expanded,
onToggle,
pad,
primaryValue,
...rest
}) => {
const { theme } = useThemeValue();

let content;
Expand Down Expand Up @@ -38,7 +45,7 @@ const ExpanderControl = ({ context, expanded, onToggle, pad, ...rest }) => {
content = (
<Button
fill
a11yTitle={expanded ? 'collapse' : 'expand'}
a11yTitle={`${expanded ? 'collapse' : 'expand'} ${primaryValue}`}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may not be human friendly (really in most cases it should be non visible id or guid)

hoverIndicator
>
plain
Expand All @@ -51,15 +58,21 @@ const ExpanderControl = ({ context, expanded, onToggle, pad, ...rest }) => {
return content;
};

const ExpanderCell = ({ background, border, context, ...rest }) => (
const ExpanderCell = ({
background,
border,
context,
primaryValue,
...rest
}) => (
<TableCell
background={background}
border={border}
size="xxsmall"
plain="noPad"
verticalAlign={context === 'groupEnd' ? 'bottom' : 'top'}
>
<ExpanderControl context={context} {...rest} />
<ExpanderControl context={context} primaryValue={primaryValue} {...rest} />
</TableCell>
);

Expand Down
1 change: 1 addition & 0 deletions src/js/components/DataTable/GroupedBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ export const GroupedBody = forwardRef(
context === 'groupHeader' ? onToggle(key) : undefined
}
expanded={expanded}
primaryValue={context === 'groupHeader' ? key : primaryValue}
verticalAlign={verticalAlign}
/>
{(selected || onSelect) && (
Expand Down
1 change: 1 addition & 0 deletions src/js/components/DataTable/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ const Header = forwardRef(
}
>
pad={cellProps.pad}
primaryValue="all"
/>
)}

Expand Down
10 changes: 5 additions & 5 deletions src/js/components/DataTable/__tests__/DataTable-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ describe('DataTable', () => {
/>
</Grommet>,
);
const expandButtons = getAllByLabelText('expand');
const expandButtons = getAllByLabelText('expand', { exact: false });
fireEvent.click(expandButtons[1], {});
expect(container.firstChild).toMatchSnapshot();
});
Expand Down Expand Up @@ -572,7 +572,7 @@ describe('DataTable', () => {
/>
</Grommet>,
);
const expandButtons = getAllByLabelText('expand');
const expandButtons = getAllByLabelText('expand', { exact: false });
fireEvent.click(expandButtons[1], {});
expect(container.firstChild).toMatchSnapshot();
});
Expand Down Expand Up @@ -879,7 +879,7 @@ describe('DataTable', () => {
</Grommet>,
);

const expandButtons = getAllByLabelText('expand');
const expandButtons = getAllByLabelText('expand', { exact: false });
fireEvent.click(expandButtons[1], {});

expect(onExpand).toBeCalled();
Expand Down Expand Up @@ -1323,7 +1323,7 @@ describe('DataTable', () => {
</Grommet>,
);
// No means to expand row details declaratively
fireEvent.click(getAllByLabelText('expand')[1]);
fireEvent.click(getAllByLabelText('expand', { exact: false })[1]);
expect(asFragment()).toMatchSnapshot();
});

Expand Down Expand Up @@ -1687,7 +1687,7 @@ describe('DataTable', () => {

const groupCheckBox = getByLabelText('select one');
fireEvent.click(groupCheckBox);
const expandButtons = getAllByLabelText('expand');
const expandButtons = getAllByLabelText('expand', { exact: false });
fireEvent.click(expandButtons[1], {});

fireEvent.click(getByLabelText('unselect 1.1'));
Expand Down
Loading
0