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

WIP(ui-calendar): add keyboard navigation and focus controll for cale… #1709

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

git-nandor
Copy link
Contributor

…ndar

@git-nandor git-nandor self-assigned this Oct 1, 2024
Copy link

github-actions bot commented Oct 1, 2024

PR Preview Action v1.4.8
🚀 Deployed preview to https://instructure.github.io/instructure-ui/pr-preview/pr-1709/
on branch gh-pages at 2024-10-01 16:56 UTC

this.locale(),
this.timezone(),
props.currentDate
const dayRefs = Array.from({ length: Calendar.DAY_COUNT }, () =>
Copy link
Contributor

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) => {
Copy link
Contributor

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
Copy link
Contributor

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)

Copy link
Contributor

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>) => {
Copy link
Contributor

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') {
Copy link
Contributor

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)}
Copy link
Contributor

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') {
Copy link
Contributor

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
Copy link
Contributor

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)

Copy link
Contributor

Choose a reason for hiding this comment

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

also maybe the dayref?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants