-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(select a11y): scroll highlighted option into view
- Loading branch information
Showing
8 changed files
with
147 additions
and
76 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
components/select/src/single-select-a11y/is-option-hidden.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export function isOptionHidden(option, scrollContainer) { | ||
const optionOffsetTop = option.getBoundingClientRect().top | ||
const optionHeight = option.offsetHeight | ||
const optionOffsetBottom = optionOffsetTop + optionHeight | ||
const containerOffsetTop = scrollContainer.getBoundingClientRect().top | ||
const containerHeight = scrollContainer.offsetHeight | ||
const containerOffsetBottom = containerOffsetTop + containerHeight | ||
|
||
return ( | ||
optionOffsetBottom > containerOffsetBottom || | ||
optionOffsetTop < containerOffsetTop | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { colors, spacers, theme } from '@dhis2/ui-constants' | ||
import { CircularLoader } from '@dhis2-ui/loader' | ||
import PropTypes from 'prop-types' | ||
import React from 'react' | ||
|
||
export function MenuLoading({ message }) { | ||
return ( | ||
<div className="container"> | ||
<div> | ||
<CircularLoader small /> | ||
</div> | ||
|
||
{message} | ||
|
||
<style jsx>{` | ||
.container { | ||
display: flex; | ||
gap: ${spacers.dp16}; | ||
align-items: center; | ||
justify-content: center; | ||
color: ${colors.grey700}; | ||
font-family: ${theme.fonts}; | ||
font-size: 13px; | ||
padding-block: ${spacers.dp8}; | ||
padding-inline: ${spacers.dp24}; | ||
} | ||
`}</style> | ||
</div> | ||
) | ||
} | ||
|
||
MenuLoading.propTypes = { | ||
message: PropTypes.string, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters