Skip to content

Commit 1c18058

Browse files
Make add to list dialog scrollable (#1689)
* make Dialog content scrollable * increase addtolistdialog query size
1 parent 24c9309 commit 1c18058

File tree

5 files changed

+20
-12
lines changed

5 files changed

+20
-12
lines changed

frontends/mit-learn/src/page-components/Dialogs/AddToListDialog.test.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ const setupLearningPaths = ({
6464
urls.learningResources.details({ id: resource.id }),
6565
resource,
6666
)
67-
setMockResponse.get(urls.learningPaths.list(), paginatedLearningPaths)
67+
setMockResponse.get(
68+
urls.learningPaths.list({ limit: 100 }),
69+
paginatedLearningPaths,
70+
)
6871
const view = renderWithProviders(null)
6972
if (dialogOpen) {
7073
act(() => {
@@ -100,7 +103,7 @@ const setupUserLists = ({
100103
urls.learningResources.details({ id: resource.id }),
101104
resource,
102105
)
103-
setMockResponse.get(urls.userLists.list(), paginatedUserLists)
106+
setMockResponse.get(urls.userLists.list({ limit: 100 }), paginatedUserLists)
104107
const view = renderWithProviders(null)
105108
if (dialogOpen) {
106109
act(() => {

frontends/mit-learn/src/page-components/Dialogs/AddToListDialog.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ import { usePostHog } from "posthog-js/react"
1414

1515
import * as NiceModal from "@ebay/nice-modal-react"
1616

17-
import {
18-
type LearningPathResource,
19-
type LearningResource,
20-
type UserList,
21-
} from "api"
17+
import type { LearningPathResource, LearningResource, UserList } from "api"
2218

2319
import {
2420
useLearningResourceSetUserListRelationships,
@@ -31,6 +27,8 @@ import { manageListDialogs } from "@/page-components/ManageListDialogs/ManageLis
3127
import { ListType } from "api/constants"
3228
import { useFormik } from "formik"
3329

30+
const LIST_LIMIT = 100
31+
3432
const ResourceTitle = styled.span({
3533
fontStyle: "italic",
3634
})
@@ -202,7 +200,7 @@ const AddToLearningPathDialogInner: React.FC<AddToListDialogProps> = ({
202200
}) => {
203201
const resourceQuery = useLearningResourcesDetail(resourceId)
204202
const resource = resourceQuery.data
205-
const listsQuery = useLearningPathsList()
203+
const listsQuery = useLearningPathsList({ limit: LIST_LIMIT })
206204

207205
const isReady = !!(resource && listsQuery.isSuccess)
208206
const lists = listsQuery.data?.results ?? []
@@ -221,7 +219,7 @@ const AddToUserListDialogInner: React.FC<AddToListDialogProps> = ({
221219
}) => {
222220
const resourceQuery = useLearningResourcesDetail(resourceId)
223221
const resource = resourceQuery.data
224-
const listsQuery = useUserListList()
222+
const listsQuery = useUserListList({ limit: LIST_LIMIT })
225223

226224
const isReady = !!(resource && listsQuery.isSuccess)
227225
const lists = listsQuery.data?.results ?? []

frontends/ol-components/src/components/Dialog/Dialog.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ const Header = styled.div`
2323
`
2424

2525
const Content = styled.div`
26-
margin: 28px 28px 40px;
26+
margin: 28px;
27+
min-height: 0;
28+
overflow: auto;
2729
`
2830

2931
const DialogActions = styled(MuiDialogActions)`

frontends/ol-components/src/components/FormDialog/FormDialog.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const FormContent = styled.div`
88
flex-direction: column;
99
gap: 20px;
1010
width: 100%;
11-
margin-bottom: -12px;
1211
`
1312
interface FormDialogProps {
1413
/**

frontends/ol-components/src/components/ThemeProvider/ThemeProvider.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,13 @@ const themeOptions: ThemeOptions = {
7777
styleOverrides: { paper: { borderRadius: "4px" } },
7878
},
7979
MuiAutocomplete: {
80-
styleOverrides: { paper: { borderRadius: "4px" } },
80+
styleOverrides: {
81+
paper: { borderRadius: "4px" },
82+
// Mui puts paddingRight: 2px, marginRight: -2px on the popupIndicator,
83+
// which causes the browser to show a horizontal scrollbar on overflow
84+
// containers when a scrollbar isn't really necessary.
85+
popupIndicator: { paddingRight: 0, marginRight: 0 },
86+
},
8187
},
8288
MuiChip: chips.chipComponent,
8389
},

0 commit comments

Comments
 (0)