Skip to content
Snippets Groups Projects
Commit a2dcfc8e authored by chris's avatar chris
Browse files

make dropdown scrollable

parent 135e8323
No related branches found
No related tags found
1 merge request!458Hhmi accessibility
...@@ -40,13 +40,15 @@ const DropDownMenu = styled.div` ...@@ -40,13 +40,15 @@ const DropDownMenu = styled.div`
border-radius: 0.25rem; border-radius: 0.25rem;
box-shadow: 0 0.2rem 0.4rem rgb(0 0 0 / 10%); box-shadow: 0 0.2rem 0.4rem rgb(0 0 0 / 10%);
margin: 10px auto auto; margin: 10px auto auto;
position: fixed; position: absolute;
width: 170px; width: 170px;
max-height: 150px;
overflow-y: scroll;
z-index: 2; z-index: 2;
span { span {
cursor: pointer; cursor: pointer;
padding: 4px 10px; padding: 8px 10px;
} }
span:focus { span:focus {
...@@ -92,6 +94,7 @@ const TableDropDown = ({ item }) => { ...@@ -92,6 +94,7 @@ const TableDropDown = ({ item }) => {
}; };
const onKeyDown = (e, index) => { const onKeyDown = (e, index) => {
e.preventDefault();
// arrow down // arrow down
if (e.keyCode === 40) { if (e.keyCode === 40) {
if (index === itemRefs.current.length - 1) { if (index === itemRefs.current.length - 1) {
...@@ -128,6 +131,7 @@ const TableDropDown = ({ item }) => { ...@@ -128,6 +131,7 @@ const TableDropDown = ({ item }) => {
aria-expanded={isOpen} aria-expanded={isOpen}
aria-haspopup aria-haspopup
onKeyDown={e => { onKeyDown={e => {
e.preventDefault();
if (e.keyCode === 40) { if (e.keyCode === 40) {
itemRefs.current[0].current.focus(); itemRefs.current[0].current.focus();
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment