Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
fix: Fix inaccessible content on public pages due to overlapping footer
Signed-off-by: Christopher Ng <[email protected]>
  • Loading branch information
Pytal committed Sep 5, 2024
commit 65ced2dd40412047a304de8d311e644ad91f5557
4 changes: 4 additions & 0 deletions core/Listener/BeforeTemplateRenderedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public function handle(Event $event): void {
Util::addScript('core', 'unsupported-browser-redirect');
}

if ($event->getResponse()->getRenderAs() === TemplateResponse::RENDER_AS_PUBLIC) {
Util::addScript('core', 'public');
}

\OC_Util::addStyle('server', null, true);

if ($event instanceof BeforeLoginTemplateRenderedEvent) {
Expand Down
14 changes: 2 additions & 12 deletions core/css/public.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,9 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#body-public {
--footer-height: calc(var(--default-line-height) + 2 * var(--default-grid-baseline));;

&:has(.footer__legal-links),
&:has(.footer__simple-sign-up) {
--footer-height: calc(2 * var(--default-line-height) + 3 * var(--default-grid-baseline));;
}

&:has(.footer__legal-links):has(.footer__simple-sign-up) {
--footer-height: calc(3 * var(--default-line-height) + 3 * var(--default-grid-baseline));
}
--footer-height: calc(2lh + 2 * var(--default-grid-baseline)); // Set the initial value, will be updated programmatically to match the actual height

.header-end {

#header-primary-action a {
color: var(--color-primary-element-text);
}
Expand Down Expand Up @@ -51,6 +41,7 @@

#content {
min-height: var(--body-height, calc(100% - var(--footer-height)));
padding-block-end: var(--footer-height);
}

#app-content-vue {
Comment on lines 42 to 47
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(unrelated:)
This will be funny once we have Vue3 apps, then there is double the padding, as currently Vue2 will replace #content with #app-content-vue, while Vue3 does not replace the mount point but the inner HTML.

Expand Down Expand Up @@ -89,7 +80,6 @@
align-items: center;
justify-content: center;

height: var(--footer-height);
width: calc(100% - 2 * var(--body-container-margin));
margin-inline: var(--body-container-margin);
padding-block: var(--default-grid-baseline);
Expand Down
26 changes: 26 additions & 0 deletions core/src/public.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

const body = document.body
const footer = document.querySelector('footer')
let prevHeight = footer?.offsetHeight

const onResize: ResizeObserverCallback = (entries) => {
for (const entry of entries) {
const height = entry.contentRect.height
if (height === prevHeight) {
return
}
prevHeight = height
body.style.setProperty('--footer-height', `${height}px`)
}
}

if (footer) {
new ResizeObserver(onResize)
.observe(footer, {
box: 'border-box', // <footer> is border-box
})
}
1 change: 1 addition & 0 deletions webpack.modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports = {
'legacy-unified-search': path.join(__dirname, 'core/src', 'legacy-unified-search.js'),
'unsupported-browser': path.join(__dirname, 'core/src', 'unsupported-browser.js'),
'unsupported-browser-redirect': path.join(__dirname, 'core/src', 'unsupported-browser-redirect.js'),
public: path.join(__dirname, 'core/src', 'public.ts'),
},
dashboard: {
main: path.join(__dirname, 'apps/dashboard/src', 'main.js'),
Expand Down