-
Notifications
You must be signed in to change notification settings - Fork 100
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
WIP(ui-calendar): add keyboard navigation and focus controll for cale… #1709
base: master
Are you sure you want to change the base?
Conversation
|
this.locale(), | ||
this.timezone(), | ||
props.currentDate | ||
const dayRefs = Array.from({ length: Calendar.DAY_COUNT }, () => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some comment about why is this needed would be nice
} | ||
} | ||
|
||
setFirstDayTabIndex = (tabIndex: number) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typing could be more restrictive, maybe tabIndex: 0 | -1
} | ||
|
||
setFirstDayTabIndex = (tabIndex: number) => { | ||
const firstDay = this.state.dayRefs[0]?.current?.firstChild as HTMLElement |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also add why the firstChild
bit is needed (because you want the button children and not the table cell)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe also call the variable firstDayButton
} | ||
|
||
handleRef = (el: Element | null) => { | ||
this.ref = el | ||
} | ||
|
||
handleOnBlur = (e: FocusEvent<Element>) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would name this function something like handleDaysTableBlur
handleOnBlur = (e: FocusEvent<Element>) => { | ||
const dataCid = e.relatedTarget?.getAttribute('data-cid') | ||
|
||
if (dataCid !== 'Day') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this needed?
{/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */} | ||
<tbody | ||
onBlur={(e) => this.handleOnBlur(e)} | ||
onKeyDown={(e) => this.handleKeyDown(e)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not needed here
this.setFirstDayTabIndex(-1) | ||
} | ||
|
||
if (typeof dayIndex === 'number') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this check is not needed, make the dayIndex
param non-optional
{role === 'presentation' | ||
? safeCloneElement(day, { | ||
'aria-describedby': this._weekdayHeaderIds[i], | ||
tabIndex: dayIndex === 0 ? 0 : -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check if the onkeydown can be added to the child prop instead of the td
(if yes, you might need to refactor the code where you call .firstChild
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also maybe the dayref?
…ndar