-
Notifications
You must be signed in to change notification settings - Fork 116
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
Fix settings menu title cut off by scrollbar #599
Fix settings menu title cut off by scrollbar #599
Conversation
Verified that @JustinHoldstock has signed the CLA. Thanks for the pull request! |
src/lib/viewers/media/Settings.js
Outdated
const { children } = menu; | ||
|
||
// If we have enough children to require scrolling, take into account scroll bar width. | ||
const scrollPadding = children.length > 7 ? 32 : 18; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extract these magic numbers to constants
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would looking at scrollHeight help?
The Element.scrollHeight read-only property is a measurement of the height of an element's content, including content not visible on the screen due to overflow.
https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight
src/lib/viewers/media/Settings.js
Outdated
// height = n * $item-height + 2 * $padding (see Settings.scss) + 2 * border (see Settings.scss) | ||
// where n is the number of displayed items in the menu | ||
const sumHeight = [].reduce.call(menu.children, (sum, child) => sum + child.offsetHeight, 0); | ||
const sumHeight = [].reduce.call(children, (sum, child) => sum + child.offsetHeight, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was taking a look at this before and was trying to figure out why it iterates over the children and sums up the offsetHeight vs taking the menu.offsetHeight. Seemed to work with the menu offsetHeight. Any ideas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not too sure, but I can confirm that menu.offsetHeight
is the way to go.
src/lib/viewers/media/Settings.js
Outdated
const { children } = menu; | ||
|
||
// If we have enough children to require scrolling, take into account scroll bar width. | ||
const scrollPadding = children.length > 7 ? 32 : 18; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would looking at scrollHeight help?
The Element.scrollHeight read-only property is a measurement of the height of an element's content, including content not visible on the screen due to overflow.
https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight
it('should add extra padding to settingsEl based on menu contents that require scroll bar', () => { | ||
const menuEl = document.createElement('div'); | ||
// Greater than enough to add a scroll bar. | ||
menuEl.appendChild(document.createElement('span')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add one element and set it's size with js?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will work especially since we're no longer counting child heights, and using offsetHeight
Fixes scroll bar cutting off menu