Skip to content

Commit

Permalink
[UI] Electron 27 fixes (Heroic-Games-Launcher#3166)
Browse files Browse the repository at this point in the history
  • Loading branch information
arielj authored Oct 28, 2023
1 parent 7f77d81 commit 5c852aa
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
12 changes: 12 additions & 0 deletions src/frontend/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,22 @@
// }
// }

// this fixes a problem with an extra horizontal scrollbar when
// a vertical scrollbar is displayed, don't change
html {
width: 100vw;
overflow-x: hidden;
}

body {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
user-select: none;
// these 2 !important fix a problem when displaying the
// context menu in the library, material ui sets values
// that create problems, don't change
overflow: visible !important;
padding: 0 !important;
}

/* Overlay Scrollbar*/
Expand Down
34 changes: 30 additions & 4 deletions src/frontend/screens/Library/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,37 @@ export default React.memo(function Library(): JSX.Element {

// we need this to do proper `position: sticky` of the Add Game area
// the height of the Header can change at runtime with different font families
// and when resizing the window
useEffect(() => {
const header = document.querySelector('.Header')
if (header) {
const headerHeight = header.getBoundingClientRect().height
document.body.style.setProperty('--header-height', `${headerHeight}px`)
let timer: NodeJS.Timeout | null = null

const setHeaderHightCSS = () => {
if (timer) clearTimeout(timer)

// adding a timeout so we don't run this for every resize event
timer = setTimeout(() => {
console.log('fired')
const header = document.querySelector('.Header')
if (header) {
const headerHeight = header.getBoundingClientRect().height
const libraryHeader = document.querySelector(
'.libraryHeader'
) as HTMLDivElement
libraryHeader &&
libraryHeader.style.setProperty(
'--header-height',
`${headerHeight}px`
)
}
}, 50)
}
// set when mounted
setHeaderHightCSS()
// also listen the resize event
window.addEventListener('resize', setHeaderHightCSS)

return () => {
window.removeEventListener('resize', setHeaderHightCSS)
}
}, [])

Expand Down

0 comments on commit 5c852aa

Please sign in to comment.