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

fix(AnalyticalTable): fire row select & click events on keyup instead of keydown #6013

Merged
merged 2 commits into from
Jul 3, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -95,12 +95,22 @@ const headerProps = (props, { instance }) => {
};

const onKeyDown = (e) => {
if (e.code === 'Space' || e.code === 'Enter') {
if (e.code === 'Enter' || e.code === 'Space') {
e.preventDefault();
if (e.code === 'Enter') {
onClick(e);
}
}
};

const onKeyUp = (e) => {
if (e.code === 'Space') {
e.preventDefault();
onClick(e);
}
};
return [props, { onClick, onKeyDown, style, title: isAllRowsSelected ? deselectAllText : selectAllText }];

return [props, { onClick, onKeyDown, onKeyUp, style, title: isAllRowsSelected ? deselectAllText : selectAllText }];
}
return props;
};
Original file line number Diff line number Diff line change
@@ -54,24 +54,40 @@ const getRowProps = (rowProps, { row, instance }) => {
}
};

const handleKeyDown = (e) => {
if ((!e.target.hasAttribute('aria-expanded') || (e.shiftKey && e.code === 'Space')) && e.code === 'Enter') {
if (
!webComponentsReactProperties.tagNamesWhichShouldNotSelectARow.has(
getTagNameWithoutScopingSuffix(e.target.tagName)
)
) {
e.preventDefault();
}
handleRowSelect(e);
}
if (e.code === 'Space') {
e.preventDefault();
}
};

const handleKeyUp = (e) => {
if (!e.target.hasAttribute('aria-expanded') && !e.shiftKey && e.code === 'Space') {
if (
!webComponentsReactProperties.tagNamesWhichShouldNotSelectARow.has(
getTagNameWithoutScopingSuffix(e.target.tagName)
)
) {
e.preventDefault();
}
handleRowSelect(e);
}
};

return [
rowProps,
{
onKeyDown: (e) => {
if (
(!e.target.hasAttribute('aria-expanded') || (e.shiftKey && e.code === 'Space')) &&
(e.key === 'Enter' || e.code === 'Space')
) {
if (
!webComponentsReactProperties.tagNamesWhichShouldNotSelectARow.has(
getTagNameWithoutScopingSuffix(e.target.tagName)
)
) {
e.preventDefault();
}
handleRowSelect(e);
}
},
onKeyDown: handleKeyDown,
onKeyUp: handleKeyUp,
onClick: handleRowSelect
}
];
Original file line number Diff line number Diff line change
@@ -93,14 +93,28 @@ export const useRowDisableSelection = (disableRowSelection: DisableRowSelectionT
}
};
const onKeyDown = (e) => {
if (e.code === 'Space' || e.code === 'Enter') {
if (e.code === 'Enter' || e.code === 'Space') {
e.preventDefault();
if (e.code === 'Enter' && typeof webComponentsReactProperties.onRowClick === 'function') {
webComponentsReactProperties.onRowClick(enrichEventWithDetails(e, { row }));
}
}
};
const onKeyUp = (e) => {
if (e.code === 'Space') {
e.preventDefault();
if (typeof webComponentsReactProperties.onRowClick === 'function') {
webComponentsReactProperties.onRowClick(enrichEventWithDetails(e, { row }));
}
}
};
return { ...rowProps, onClick: handleClick, onKeyDown, className: webComponentsReactProperties.classes.tr };
return {
...rowProps,
onClick: handleClick,
onKeyDown,
onKeyUp,
className: webComponentsReactProperties.classes.tr
};
}
return rowProps;
};

Unchanged files with check annotations Beta

function ResizeTestComponent({ onChange }: { onChange: (event: { width: number; height: number }) => void }) {
useEffect(() => {
attachResizeHandler(onChange);
}, []);

Check warning on line 12 in packages/base/src/Device/index.cy.tsx

GitHub Actions / lint

React Hook useEffect has a missing dependency: 'onChange'. Either include it or remove the dependency array
const unregister = () => {
detachResizeHandler(onChange);
}) {
useEffect(() => {
attachOrientationChangeHandler(onChange);
}, []);

Check warning on line 32 in packages/base/src/Device/index.cy.tsx

GitHub Actions / lint

React Hook useEffect has a missing dependency: 'onChange'. Either include it or remove the dependency array
const unregister = () => {
detachOrientationChangeHandler(onChange);
* @param measure {IChartMeasure} Current measure object
* @param dataElement {object} Current data element
*/
highlightColor?: (value: number, measure: MeasureConfig, dataElement: Record<string, any>) => CSSProperties['color'];

Check warning on line 79 in packages/charts/src/components/BarChart/BarChart.tsx

GitHub Actions / lint

Unexpected any. Specify a different type
}
interface DimensionConfig extends IChartDimension {
? dataKeys.findIndex((key) => key === chartConfig.secondYAxis?.dataKey)
: 0;
const [componentRef, chartRef] = useSyncRef<any>(ref);

Check warning on line 188 in packages/charts/src/components/BarChart/BarChart.tsx

GitHub Actions / lint

Unexpected any. Specify a different type
const onItemLegendClick = useLegendItemClick(onLegendClick);
const labelFormatter = useLabelFormatter(primaryDimension);
speed={2}
backgroundColor={ThemingParameters.sapContent_ImagePlaceholderBackground}
foregroundColor={ThemingParameters.sapContent_ImagePlaceholderForegroundColor}
backgroundOpacity={ThemingParameters.sapContent_DisabledOpacity as any}

Check warning on line 15 in packages/charts/src/components/BarChart/Placeholder.tsx

GitHub Actions / lint

Unexpected any. Specify a different type
>
<rect x="20" y="10" width="1" height="135" />
<rect x="20" y="20" width="85" height="15" />
* @param measure {IChartMeasure} Current measure object
* @param dataElement {object} Current data element
*/
highlightColor?: (value: number, measure: MeasureConfig, dataElement: Record<string, any>) => CSSProperties['color'];

Check warning on line 69 in packages/charts/src/components/BulletChart/BulletChart.tsx

GitHub Actions / lint

Unexpected any. Specify a different type
}
interface DimensionConfig extends IChartDimension {
...rest
} = props;
const [componentRef, chartRef] = useSyncRef<any>(ref);

Check warning on line 148 in packages/charts/src/components/BulletChart/BulletChart.tsx

GitHub Actions / lint

Unexpected any. Specify a different type
const chartConfig: BulletChartProps['chartConfig'] = {
yAxisVisible: false,
);
} else {
onDataPointClick(
enrichEventWithDetails({} as any, {

Check warning on line 227 in packages/charts/src/components/BulletChart/BulletChart.tsx

GitHub Actions / lint

Unexpected any. Specify a different type
value: eventOrIndex.value,
dataKey: eventOrIndex.dataKey,
dataIndex: eventOrIndex.index,
{chartConfig.xAxisVisible &&
dimensions.map((dimension, index) => {
let AxisComponent;
const axisProps: any = {

Check warning on line 302 in packages/charts/src/components/BulletChart/BulletChart.tsx

GitHub Actions / lint

Unexpected any. Specify a different type
dataKey: dimension.accessor,
interval: dimension?.interval ?? (isBigDataSet ? 'preserveStart' : 0),
tickLine: index < 1,
/>
)}
{sortedMeasures?.map((element, index) => {
const chartElementProps: any = {

Check warning on line 440 in packages/charts/src/components/BulletChart/BulletChart.tsx

GitHub Actions / lint

Unexpected any. Specify a different type
isAnimationActive: !noAnimation
};
let labelPosition = 'top';