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: Button pressed state and lists #940

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
41 changes: 26 additions & 15 deletions packages/react-calendar/src/Flex.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Children, cloneElement } from 'react';

type FlexProps = React.HTMLAttributes<HTMLDivElement> & {
type FlexProps = React.HTMLAttributes<HTMLUListElement> & {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
children: React.ReactElement<any>[];
className?: string;
Expand All @@ -26,32 +26,43 @@ export default function Flex({
...otherProps
}: FlexProps) {
return (
<div
<ul
className={className}
style={{
display: 'flex',
flexDirection: direction,
flexWrap: wrap ? 'wrap' : 'nowrap',
margin: 0,
padding: 0,
...style,
}}
{...otherProps}
>
{Children.map(children, (child, index) => {
const marginInlineStart = offset && index === 0 ? toPercent((100 * offset) / count) : null;

return cloneElement(child, {
...child.props,
style: {
flexBasis: toPercent(100 / count),
flexShrink: 0,
flexGrow: 0,
overflow: 'hidden',
marginLeft: marginInlineStart,
marginInlineStart: marginInlineStart,
marginInlineEnd: 0,
},
});
return (
<li
style={{
display: 'flex',
flexBasis: toPercent(100 / count),
flexShrink: 0,
flexGrow: 0,
overflow: 'hidden',
marginLeft: marginInlineStart || undefined,
marginInlineStart: marginInlineStart || undefined,
marginInlineEnd: 0,
}}
>
{cloneElement(child, {
...child.props,
style: {
flex: 1,
},
})}
</li>
);
})}
</div>
</ul>
);
}
1 change: 1 addition & 0 deletions packages/react-calendar/src/Tile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export default function Tile(props: TileProps) {
onMouseOver={onMouseOver ? () => onMouseOver(date) : undefined}
style={style}
type="button"
aria-pressed={!!classes?.find((classString) => classString.indexOf('--active') != -1)}
tskarhed marked this conversation as resolved.
Show resolved Hide resolved
>
{formatAbbr ? <abbr aria-label={formatAbbr(locale, date)}>{children}</abbr> : children}
{tileContent}
Expand Down