Skip to content

Commit

Permalink
Merge pull request #12513 from rtibbles/keypad_behave
Browse files Browse the repository at this point in the history
Fix keypad and tab navigation issues in exercises
  • Loading branch information
marcellamaki authored Aug 1, 2024
2 parents 85dcf2b + 0bcca51 commit 69242d3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ oriented data synchronization.
/>
<KButton
v-else
ref="nextButton"
appearance="raised-button"
:text="$tr('next')"
:primary="true"
Expand Down Expand Up @@ -418,6 +419,11 @@ oriented data synchronization.
}
this.complete = correct === 1;
this.updateAttempt({ answerState, simpleAnswer });
if (this.complete) {
this.$nextTick(() => {
this.$refs.nextButton.$el.focus();
});
}
},
hintTaken({ answerState }) {
this.hintWasTaken = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
v-if="itemId || itemData"
class="bibliotron-exercise perseus-root"
:class="{ 'perseus-mobile': isMobile }"
@keydown.enter="answerGiven"
@keydown.enter.prevent="answerGiven"
>
<div
class="framework-perseus"
Expand Down Expand Up @@ -57,6 +57,7 @@
const keypadStyle = StyleSheet.create({
keypadContainer: {
zIndex: 20,
pointerEvents: 'none',
},
});
Expand Down Expand Up @@ -429,7 +430,16 @@
createPortal(
e(MobileKeypad, {
style: keypadStyle.keypadContainer,
onElementMounted: setKeypadElement,
onElementMounted: el => {
// We need to add the class to the container element
// but the MobileKeypad component does not pass through
// React's className prop to the root element.
const domNode = el.getDOMNode();
if (domNode) {
domNode.classList.add('perseus-keypad-container');
}
setKeypadElement(el);
},
onDismiss: () => renderer && renderer.blur(),
onAnalyticsEvent: async () => {},
}),
Expand Down Expand Up @@ -973,4 +983,8 @@
}
}
.perseus-keypad-container > div > div {
pointer-events: auto;
}
</style>

0 comments on commit 69242d3

Please sign in to comment.