FIX: Cleaned up horizontal nav scrolling so arrows show/hide properly (#30621)

This commit is contained in:
Ella E. 2025-01-07 18:07:44 -07:00 committed by GitHub
parent 4f9359d056
commit a88c86beef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -47,14 +47,21 @@ export default class HorizontalOverflowNav extends Component {
}
watchScroll(element) {
if (element.offsetWidth + element.scrollLeft === element.scrollWidth) {
const { scrollWidth, scrollLeft, offsetWidth } = element;
// Check if the content overflows
this.hasScroll = scrollWidth > offsetWidth;
// Ensure the right arrow disappears only when fully scrolled
if (scrollWidth - scrollLeft - offsetWidth <= 2) {
this.hideRightScroll = true;
clearInterval(this.scrollInterval);
} else {
this.hideRightScroll = false;
}
if (element.scrollLeft === 0) {
// Ensure the left arrow disappears only when fully scrolled to the start
if (scrollLeft <= 2) {
this.hideLeftScroll = true;
clearInterval(this.scrollInterval);
} else {