diff --git a/resources/vue/components/courseware/CoursewareRibbonToolbar.vue b/resources/vue/components/courseware/CoursewareRibbonToolbar.vue
index edf356e545f9e469ac16486b0f79379d96e934fb..716bf457d294fa419913ee6a32ad3da57c0e391d 100644
--- a/resources/vue/components/courseware/CoursewareRibbonToolbar.vue
+++ b/resources/vue/components/courseware/CoursewareRibbonToolbar.vue
@@ -125,7 +125,7 @@ export default {
             return this.userIsTeacher;
         },
         fallbackFocusElement(){
-            return this.$refs.tabs.getTabButtonByAlias(this.selectedToolbarItem);
+            return this.$refs.contents;
         }
     },
     methods: {
@@ -192,9 +192,10 @@ export default {
             }
         },
         toolsActive(newValue) {
-            if (newValue) {
+            const focusElement = this.$refs.tabs.getTabButtonByAlias(this.selectedToolbarItem);
+            if (newValue && focusElement) {
                 setTimeout(() => {
-                    this.initialFocusElement = this.$refs.tabs.getTabButtonByAlias(this.selectedToolbarItem);
+                    this.initialFocusElement = focusElement;
                     this.trap = true;
                 }, 300);
             }