Skip to content

Commit

Permalink
fixup! fix(NcAppSidebar): make sidebar a single node to allow using v…
Browse files Browse the repository at this point in the history
…-show
  • Loading branch information
ShGKme committed Jun 19, 2024
1 parent fbedef5 commit bd32d5d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/components/NcAppSidebar/NcAppSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ export default {
So we cannot render the toggle button directly in this component.
As a simple solution - render it in the content to keep correct position.
-->
<Teleport v-if="!open && !noToggle" selector="#content-vue">
<Teleport v-if="ncContentSelector && !open && !noToggle" :selector="ncContentSelector">
<NcButton :aria-label="t('Open sidebar')"
class="app-sidebar__toggle"
:class="toggleClasses"
Expand Down Expand Up @@ -738,6 +738,13 @@ export default {
ClickOutside,
},
inject: {
ncContentSelector: {
from: 'NcContent:selector',
default: undefined,
},
},
props: {
active: {
type: String,
Expand Down Expand Up @@ -941,11 +948,15 @@ export default {
open() {
this.toggleFocusTrap()
this.checkToggleButtonContainerAvailability()
},
},
created() {
this.preserveElementToReturnFocus()
this.checkToggleButtonContainerAvailability()
},
mounted() {
Expand Down Expand Up @@ -1145,6 +1156,19 @@ export default {
this.$refs.tabs.focusActiveTabContent()
},
/**
* Check if the toggle button container is available
*/
checkToggleButtonContainerAvailability() {
// Toggle button must be rendered, but there is no element to teleport it to
if (this.open === false && !this.noToggle && !this.ncContentSelector) {
console.warn(
'[NcAppSidebar] It looks like you want to use NcAppSidebar with the built-in toggle button. '
+ 'This feature is only available when NcAppSidebar is used in NcContent.',
)
}
},
/**
* Emit name change event to parent component
*
Expand Down
1 change: 1 addition & 0 deletions src/components/NcContent/NcContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export default {
provide() {
return {
'NcContent:setHasAppNavigation': this.setAppNavigation,
'NcContent:selector': '#content-vue',
}
},
props: {
Expand Down

0 comments on commit bd32d5d

Please sign in to comment.