-
Notifications
You must be signed in to change notification settings - Fork 21
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
feat(slider): add range
mode accessibility support
#332
Conversation
Deploying with Cloudflare Pages
|
@@ -598,18 +598,27 @@ export class Slider extends ControlElement { | |||
return; | |||
} | |||
|
|||
this.changedThumb = event.target as HTMLDivElement; | |||
const thumbName = this.changedThumb.getAttribute('name') as SliderDataName; |
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.
Can you detect the thumb name in different name, e.g. if you hold the reference to thumb:
private getThumbName (target: EventTarget): SliderDataName | null {
if (target === this.thumbFromRef.value) {
return SliderDataName.from;
}
// return ....
}
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.
Added ref to thumbs and refactor a bit on thumb related logics.
* @param type from or to | ||
* @returns validated from or to | ||
*/ | ||
private validateRange (value: string, type: SliderDataName): string { |
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 this function needs better comment. I am not sure what does it try to validate
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.
It was a wrapper function of validateFrom
and validateTo
. I've decided to remove it and improve code comment.
SonarCloud Quality Gate failed. |
) * chore: update package-lock * feat(slider): add arrow key support and add aria attributes * test: refactor test structure and add test for arrow key interactions * refactor: update variable names and fix typo * feat: add focus outline style to thumb * feat: remove input focus and focus thumb on drag * feat: simplify `validateNumber` util function * test: update snapshot * fix: detect keyboard focus state from host * fix: use tabIndex=1 instead * feat: introduce `active` attribute for thumb * feat: add logic to adds/removes `active` thumb focus style and add generic labels to slider and input * test: update snapshots * refactor: reuse `calculatePercentage` function * fix: add min more than max case * fix: remove invalid number checking on `calculatePercentage` * refactor: improve variable name * fix: add disabled back to number-field * refactor: replace the term `percentageValue` with thumbPosition for consistency * refactor: replace 5,10 z-index with 3,4 respectively and add comments why * refactor: remove `validateNumber` * fix: remove input label * test: extract private getters to a function and remove describe layer * refactor: rename `calculatePercentage` to `calculatePosition` * refactor: thumb logic and use `@state` * feat: ignore special characters onKeyDown * refactor: remove percentage reference and initialise * fix: add `defaultPrevented` onkeydown * feat(slider): add `range` mode accessibility support (#332) * feat(slider): add `range` mode accessibility support * feat(slider): hide number-field inputs from tab sequence and screen reader * fix: switch Home and End logic * docs: remove deupllicated demo * refactor: improve code readability * refactor: keeping thumb as refs Co-authored-by: wsuwt <[email protected]> * docs(slider): add slider a11y docs (#341) * feat(slider): add `range` mode accessibility support * feat(slider): hide number-field inputs from tab sequence and screen reader * fix: switch Home and End logic * docs: remove deupllicated demo * docs(slider): add slider a11y docs Co-authored-by: wsuwt <[email protected]> Co-authored-by: wsuwt <[email protected]>
Description
range
modeHome
andEnd
supportType of change
Checklist