Skip to content
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

Accessibility, keyboard nav, major bug fixes #5

Merged
merged 13 commits into from
May 22, 2020
Merged

Conversation

dtassone
Copy link
Member

Added keyboard navigation/selection, added aria attributes, fix major issue with virtualisation

@dtassone dtassone merged commit 0ad5f5d into master May 22, 2020
@oliviertassinari oliviertassinari deleted the accessibility branch May 24, 2020 21:50
@@ -26,10 +41,14 @@ export const Cell: React.FC<GridCellProps> = React.memo(
return (
<div
className={cssClasses}
role={field + ' cell'}
role={'cell'}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
role={'cell'}
role="cell"

@@ -31,8 +31,17 @@ export const CommodityGridDemo: React.FC<{}> = props => {
setCols(gridColumns);
setLoading(true);

loadFile(`./static-data/${type}-${size}.json`).then(
loadFile(`./static-data/${type}-1000.json`).then(
Copy link
Member

Choose a reason for hiding this comment

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

⚠️ with the clean-up. I would recommend the following: https://github.com/mui-org/material-ui/blob/90babbd13d8dc624ff23453a4e47a311e2758aa6/docs/src/pages/components/autocomplete/Asynchronous.tsx#L23-L43. Notice the active variable that avoids calling setState on an unmounted component (if the request resolves after the unmount).

StatusRenderer,
} from './renderer';

const totalPriceFormatter = ({ value }) => `$ ${Number(value).toLocaleString()}`;
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure about the space between $ and the figures?

console.log(new Intl.NumberFormat("en-US", {style: "currency", currency: "USD"}).format(121));
// $121.00.

} from './renderer';

const totalPriceFormatter = ({ value }) => `$ ${Number(value).toLocaleString()}`;
const pnlFormatter = params =>
Copy link
Member

Choose a reason for hiding this comment

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

We have applied the following coding convention so far: top-level scope => named function, nested-level scope => arrow function. In this context, it would turn into

function pnlFormatter(params) {

if we want to keep following this convention.

import React from 'react';

export function RatingRenderer(params: CellParams) {
return <Rating name={params.data['id'].toString()} value={Number(params.value)} readOnly />;
Copy link
Member

Choose a reason for hiding this comment

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

Maybe?

-return <Rating name={params.data['id'].toString()} value={Number(params.value)} readOnly />;
+return <Rating name={params.data.id.toString()} value={Number(params.value)} readOnly />;

@@ -19,10 +20,16 @@ export const ColumnHeaderSortIcon: React.FC<ColumnHeaderSortIconProps> = React.m
<span className={'sort-icon'}>
{index != null && (
<Badge badgeContent={index} color="default">
{icons[direction]}
<IconButton aria-label="Sort" size="small">
Copy link
Member

Choose a reason for hiding this comment

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

We prefer not to capitalize on the label, as far as I know, it makes no difference during pronunciation.

<IconButton aria-label="sort" size="small">

@@ -7,7 +7,7 @@ const ColumnHeaderInnerTitle = React.forwardRef<HTMLDivElement, any>((props, ref
const { label, className, ...rest } = props;

return (
<div ref={ref} className={'title ' + className} {...rest} role={'column-header-title'}>
<div ref={ref} className={'title ' + className} {...rest} role={'column-header-title'} aria-label={label}>
Copy link
Member

Choose a reason for hiding this comment

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

<div ref={ref} className={'title ' + className} role={'column-header-title'} aria-label={label} {...rest}>

/>
));

return <>{items}</>;
Copy link
Member

Choose a reason for hiding this comment

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

I would expect it to work without a Fragment.

return items;

nextCellIndexes.colIndex = nextCellIndexes.colIndex >= colCount ? colCount - 1 : nextCellIndexes.colIndex;

apiRef.current!.scrollToIndexes(nextCellIndexes);
setTimeout(() => {
Copy link
Member

Choose a reason for hiding this comment

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

It seems we miss a clean-up.


//This a hack due to the limitation of react as I cannot put columnsRef in the dependency array of the effect adding the Event listener
Copy link
Member

Choose a reason for hiding this comment

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

I would love to have a chat about how we can improve the approach

@oliviertassinari
Copy link
Member

oliviertassinari commented May 24, 2020

Regarding react-hooks/exhaustive-deps I think that it would be valuable to turn the rule into an error. It should almost never be necessary to ignore the rule. From experience, anytime we ignore this warning, a developer will raise a bug, later down the road.

@oliviertassinari
Copy link
Member

  • Is it expected that the Grid container can receive the focus?
  • keyboard control can be brittle, adding a test case per command could help.
  • I have just tried Control + Home, pretty cool 👌.
  • Should we send this codesandbox to Josh so he can try it out https://mf8le.csb.app/?
  • I believe the behavior on the header is not correct, in respect to how the sorting can be triggered. However, happy to revisit later.

@dtassone dtassone restored the accessibility branch May 26, 2020 10:05
@oliviertassinari oliviertassinari deleted the accessibility branch May 27, 2020 11:03
@dtassone dtassone restored the accessibility branch May 27, 2020 17:25
@dtassone dtassone deleted the accessibility branch July 21, 2020 14:33
michaldudak added a commit to michaldudak/mui-x that referenced this pull request Sep 21, 2021
* Make chart docs great again

* [Charts] Fix Popper complaining about not being anchored to a DOM element

* [Charts] Fix infinite render loop in Line
@oliviertassinari oliviertassinari added the component: data grid This is the name of the generic UI component, not the React module! label Jan 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants