Skip to content

[6.0] Prevent issues when storing the top offset in AdjustableSidebarWidth #827

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
>
<div :id="AppTopID" />
<a href="#main" id="skip-nav" v-if="!isTargetIDE">{{ $t('accessibility.skip-navigation') }}</a>
<InitialLoadingPlaceholder />
<slot name="header" :isTargetIDE="isTargetIDE">
<SuggestLang v-if="enablei18n" />
<!-- Render the custom header by default, if there is no content in the `header` slot -->
<custom-header v-if="hasCustomHeader" :data-color-scheme="preferredColorScheme" />
</slot>
<!-- The nav sticky anchor has to always be between the Header and the Content -->
<div :id="baseNavStickyAnchorId" />
<InitialLoadingPlaceholder />
<slot :isTargetIDE="isTargetIDE">
<router-view class="router-content" />
<custom-footer v-if="hasCustomFooter" :data-color-scheme="preferredColorScheme" />
Expand Down
29 changes: 19 additions & 10 deletions tests/unit/App.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,19 +180,34 @@ describe('App', () => {
expect(wrapper.find(LocaleSelector).exists()).toBe(false);
});

it('renders the `#nav-sticky-anchor` between the header and the content', () => {
it('renders the `#nav-sticky-anchor` between the header and loading placeholder', () => {
const wrapper = createWrapper({
slots: {
header: '<div class="header">Footer</div>',
default: '<div class="default">Default</div>',
},
});
const header = wrapper.find('.header');
const content = wrapper.find('.default');
const stickyAnchor = wrapper.find(`#${baseNavStickyAnchorId}`);
const loadingPlaceholder = wrapper.find(InitialLoadingPlaceholder);

// make sure the anchor is below the header and above the content
expect(header.element.nextElementSibling).toBe(stickyAnchor.element);
expect(stickyAnchor.element.nextElementSibling).toBe(content.element);
expect(stickyAnchor.element.nextElementSibling).toBe(loadingPlaceholder.element);
});

it('renders an `InitialLoadingPlaceholder` between the anchor and the content', () => {
const wrapper = createWrapper({
slots: {
default: '<div class="default">Default</div>',
},
});
const stickyAnchor = wrapper.find(`#${baseNavStickyAnchorId}`);
const content = wrapper.find('.default');
const placeholder = wrapper.find(InitialLoadingPlaceholder);
// make sure the anchor is below the header and above the content
expect(placeholder.exists()).toBe(true);
expect(stickyAnchor.element.nextElementSibling).toBe(placeholder.element);
expect(placeholder.element.nextElementSibling).toBe(content.element);
});

it('exposes a footer slot', () => {
Expand All @@ -216,12 +231,6 @@ describe('App', () => {
expect(wrapper.find('router-view-stub').exists()).toBe(false);
});

it('renders an `InitialLoadingPlaceholder`', () => {
const wrapper = createWrapper();

expect(wrapper.find(InitialLoadingPlaceholder).exists()).toBe(true);
});

it('renders a default `Footer` for non-IDE targets', () => {
const wrapper = createWrapper();
expect(wrapper.contains(Footer)).toBe(true);
Expand Down