Skip to content

Commit 9423a88

Browse files
fix: fixed units overflow issue (openedx#1343)
* fix: fixed units overflow issue * refactor: refactor code for desktop and xl screen * refactor: fixed refactor issue
1 parent 85b95ad commit 9423a88

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/courseware/course/sequence/sequence-navigation/SequenceNavigationTabs.jsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3+
import classNames from 'classnames';
34

45
import UnitButton from './UnitButton';
56
import SequenceNavigationDropdown from './SequenceNavigationDropdown';
67
import useIndexOfLastVisibleChild from '../../../../generic/tabs/useIndexOfLastVisibleChild';
8+
import { useIsOnXLDesktop } from './hooks';
79

810
const SequenceNavigationTabs = ({
911
unitIds, unitId, showCompletion, onNavigate,
@@ -13,11 +15,17 @@ const SequenceNavigationTabs = ({
1315
containerRef,
1416
invisibleStyle,
1517
] = useIndexOfLastVisibleChild();
18+
const isOnXLDesktop = useIsOnXLDesktop();
1619
const shouldDisplayDropdown = indexOfLastVisibleChild === -1;
1720

1821
return (
1922
<div style={{ flexBasis: '100%', minWidth: 0 }}>
20-
<div className="sequence-navigation-tabs-container" ref={containerRef}>
23+
<div
24+
ref={containerRef}
25+
className={classNames('sequence-navigation-tabs-container', {
26+
'navigation-tab-width': isOnXLDesktop && shouldDisplayDropdown,
27+
})}
28+
>
2129
<div
2230
className="sequence-navigation-tabs d-flex flex-grow-1"
2331
style={shouldDisplayDropdown ? invisibleStyle : null}

src/courseware/course/sequence/sequence-navigation/hooks.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint-disable import/prefer-default-export */
22

33
import { useSelector } from 'react-redux';
4+
import { breakpoints, useWindowSize } from '@openedx/paragon';
45
import { useModel } from '../../../../generic/model-store';
56
import { sequenceIdsSelector } from '../../../data';
67

@@ -68,3 +69,8 @@ export function useSequenceNavigationMetadata(currentSequenceId, currentUnitId)
6869
navigationDisabledPrevSequence,
6970
};
7071
}
72+
73+
export function useIsOnXLDesktop() {
74+
const windowSize = useWindowSize();
75+
return windowSize.width >= breakpoints.extraLarge.minWidth;
76+
}

src/index.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@
173173
}
174174
}
175175

176+
.navigation-tab-width {
177+
max-width: 30rem;
178+
}
179+
176180
.sequence-navigation-dropdown {
177181
.dropdown-menu .btn {
178182
flex-basis: 100%;

0 commit comments

Comments
 (0)