Skip to content

Commit

Permalink
- Add underline text decoration
Browse files Browse the repository at this point in the history
- Fixed bug in Modal that caused it to crash when tabbing or shift tabbing with only one button
  • Loading branch information
elipe17 committed Dec 11, 2024
1 parent 08c346a commit eab0955
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions tdrs-frontend/src/assets/Reports.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
border: none;
color: #264A64;
text-align: left;
text-decoration: underline;
margin: 0;
padding: 0;
}
Expand Down
10 changes: 4 additions & 6 deletions tdrs-frontend/src/components/Modal/Modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,17 @@ const Modal = ({ title, message, buttons = [], isVisible = false }) => {
(b) => b.key === selectedButtonKey
)

const btnIdxMinOne = Math.max(0, buttons.length - 1)
if (shiftKey) {
// go backward
const selectedIdxMinOne = Math.max(0, selectedButtonIndex - 1)
nextButtonIndex =
selectedButtonIndex >= 0
? selectedButtonIndex - 1
: buttons.length - 1
selectedButtonIndex >= 0 ? selectedIdxMinOne : btnIdxMinOne
} else {
nextButtonIndex =
selectedButtonIndex < buttons.length - 1 ? selectedButtonIndex + 1 : 0
selectedButtonIndex < btnIdxMinOne ? selectedButtonIndex + 1 : 0
}
}

const nextButtonKey = buttons[nextButtonIndex].key
const nextButton = modalRef.current.querySelector(
`button[buttonkey="${nextButtonKey}"]`
Expand All @@ -45,7 +44,6 @@ const Modal = ({ title, message, buttons = [], isVisible = false }) => {

const onKeyDown = (e) => {
const { key, shiftKey } = e

switch (key) {
case 'Tab':
onTabPressed(shiftKey)
Expand Down

0 comments on commit eab0955

Please sign in to comment.