Skip to content

Commit 7e0940f

Browse files
marinaaisahqhhuang
andauthored
Prevent issues when storing the top offset in AdjustableSidebarWidth (#826)
Moving the placeholder element helps resolve an issue where an offset for the navigator may be incorrectly calculated when the initial loading placeholder is still on-screen, since it takes up the full viewport height. Resolves: rdar://128197719 Co-authored-by: Hanqing Huang <[email protected]>
1 parent c9e9ef3 commit 7e0940f

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
>
1616
<div :id="AppTopID" />
1717
<a href="#main" id="skip-nav" v-if="!isTargetIDE">{{ $t('accessibility.skip-navigation') }}</a>
18-
<InitialLoadingPlaceholder />
1918
<slot name="header" :isTargetIDE="isTargetIDE">
2019
<SuggestLang v-if="enablei18n" />
2120
<!-- Render the custom header by default, if there is no content in the `header` slot -->
2221
<custom-header v-if="hasCustomHeader" :data-color-scheme="preferredColorScheme" />
2322
</slot>
2423
<!-- The nav sticky anchor has to always be between the Header and the Content -->
2524
<div :id="baseNavStickyAnchorId" />
25+
<InitialLoadingPlaceholder />
2626
<slot :isTargetIDE="isTargetIDE">
2727
<router-view class="router-content" />
2828
<custom-footer v-if="hasCustomFooter" :data-color-scheme="preferredColorScheme" />

tests/unit/App.spec.js

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -180,19 +180,34 @@ describe('App', () => {
180180
expect(wrapper.find(LocaleSelector).exists()).toBe(false);
181181
});
182182

183-
it('renders the `#nav-sticky-anchor` between the header and the content', () => {
183+
it('renders the `#nav-sticky-anchor` between the header and loading placeholder', () => {
184184
const wrapper = createWrapper({
185185
slots: {
186186
header: '<div class="header">Footer</div>',
187-
default: '<div class="default">Default</div>',
188187
},
189188
});
190189
const header = wrapper.find('.header');
191-
const content = wrapper.find('.default');
192190
const stickyAnchor = wrapper.find(`#${baseNavStickyAnchorId}`);
191+
const loadingPlaceholder = wrapper.find(InitialLoadingPlaceholder);
192+
193193
// make sure the anchor is below the header and above the content
194194
expect(header.element.nextElementSibling).toBe(stickyAnchor.element);
195-
expect(stickyAnchor.element.nextElementSibling).toBe(content.element);
195+
expect(stickyAnchor.element.nextElementSibling).toBe(loadingPlaceholder.element);
196+
});
197+
198+
it('renders an `InitialLoadingPlaceholder` between the anchor and the content', () => {
199+
const wrapper = createWrapper({
200+
slots: {
201+
default: '<div class="default">Default</div>',
202+
},
203+
});
204+
const stickyAnchor = wrapper.find(`#${baseNavStickyAnchorId}`);
205+
const content = wrapper.find('.default');
206+
const placeholder = wrapper.find(InitialLoadingPlaceholder);
207+
// make sure the anchor is below the header and above the content
208+
expect(placeholder.exists()).toBe(true);
209+
expect(stickyAnchor.element.nextElementSibling).toBe(placeholder.element);
210+
expect(placeholder.element.nextElementSibling).toBe(content.element);
196211
});
197212

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

219-
it('renders an `InitialLoadingPlaceholder`', () => {
220-
const wrapper = createWrapper();
221-
222-
expect(wrapper.find(InitialLoadingPlaceholder).exists()).toBe(true);
223-
});
224-
225234
it('renders a default `Footer` for non-IDE targets', () => {
226235
const wrapper = createWrapper();
227236
expect(wrapper.contains(Footer)).toBe(true);

0 commit comments

Comments
 (0)