From 6c743f858ddb4f66f78a9bf1d960443e600a4f08 Mon Sep 17 00:00:00 2001 From: Kristin Aoki <42981026+KristinAoki@users.noreply.github.com> Date: Wed, 22 May 2024 12:02:25 -0400 Subject: [PATCH] fix: video selection gallery scroll (#477) * fix: video selection gallery scroll * fix: lint errors --- .../VideoEditor/components/BaseModal.jsx | 52 ------------------- .../components/SelectVideoModal.jsx | 2 +- src/editors/containers/VideoGallery/index.jsx | 46 ++++++++-------- .../__snapshots__/index.test.jsx.snap | 8 +-- .../sharedComponents/BaseModal/index.jsx | 9 ++-- .../SelectionModal/Gallery.jsx | 42 +++++++-------- .../sharedComponents/SelectionModal/index.jsx | 2 +- .../SelectionModal/index.scss | 2 +- .../__snapshots__/index.test.jsx.snap | 12 ++--- .../SourceCodeModal/index.jsx | 7 ++- src/setupTest.js | 2 +- 11 files changed, 69 insertions(+), 115 deletions(-) delete mode 100644 src/editors/containers/VideoEditor/components/BaseModal.jsx diff --git a/src/editors/containers/VideoEditor/components/BaseModal.jsx b/src/editors/containers/VideoEditor/components/BaseModal.jsx deleted file mode 100644 index 9a72d53d9..000000000 --- a/src/editors/containers/VideoEditor/components/BaseModal.jsx +++ /dev/null @@ -1,52 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; - -import { - ActionRow, - ModalDialog, -} from '@openedx/paragon'; - -export const BaseModal = ({ - isOpen, - close, - title, - children, - confirmAction, -}) => ( - - - - {title} - - - - {children} - - - - - Cancel - - {confirmAction} - - - -); - -BaseModal.propTypes = { - isOpen: PropTypes.bool.isRequired, - close: PropTypes.func.isRequired, - title: PropTypes.node.isRequired, - children: PropTypes.node.isRequired, - confirmAction: PropTypes.node.isRequired, -}; - -export default BaseModal; diff --git a/src/editors/containers/VideoEditor/components/SelectVideoModal.jsx b/src/editors/containers/VideoEditor/components/SelectVideoModal.jsx index 6058ef1e3..ade441c32 100644 --- a/src/editors/containers/VideoEditor/components/SelectVideoModal.jsx +++ b/src/editors/containers/VideoEditor/components/SelectVideoModal.jsx @@ -5,7 +5,7 @@ import PropTypes from 'prop-types'; import { Button } from '@openedx/paragon'; import { thunkActions } from '../../../data/redux'; -import BaseModal from './BaseModal'; +import BaseModal from '../../../sharedComponents/BaseModal'; import * as module from './SelectVideoModal'; export const hooks = { diff --git a/src/editors/containers/VideoGallery/index.jsx b/src/editors/containers/VideoGallery/index.jsx index 8206149e3..8973a0952 100644 --- a/src/editors/containers/VideoGallery/index.jsx +++ b/src/editors/containers/VideoGallery/index.jsx @@ -56,28 +56,30 @@ export const VideoGallery = () => { ); return ( - +
+ +
); }; diff --git a/src/editors/sharedComponents/BaseModal/__snapshots__/index.test.jsx.snap b/src/editors/sharedComponents/BaseModal/__snapshots__/index.test.jsx.snap index 449a753f4..78f87cd61 100644 --- a/src/editors/sharedComponents/BaseModal/__snapshots__/index.test.jsx.snap +++ b/src/editors/sharedComponents/BaseModal/__snapshots__/index.test.jsx.snap @@ -23,11 +23,13 @@ exports[`BaseModal ImageUploadModal template component snapshot 1`] = ` props.title node - - props.children node - + + props.children node + + props.footerAction node diff --git a/src/editors/sharedComponents/BaseModal/index.jsx b/src/editors/sharedComponents/BaseModal/index.jsx index 9550e9f64..dd1bef748 100644 --- a/src/editors/sharedComponents/BaseModal/index.jsx +++ b/src/editors/sharedComponents/BaseModal/index.jsx @@ -4,6 +4,7 @@ import PropTypes from 'prop-types'; import { ActionRow, ModalDialog, + Scrollable, } from '@openedx/paragon'; import { FormattedMessage } from '@edx/frontend-platform/i18n'; @@ -39,9 +40,11 @@ export const BaseModal = ({ {headerComponent} - - {children} - + + + {children} + + {footerAction} diff --git a/src/editors/sharedComponents/SelectionModal/Gallery.jsx b/src/editors/sharedComponents/SelectionModal/Gallery.jsx index 8c9162ad4..5c54605e6 100644 --- a/src/editors/sharedComponents/SelectionModal/Gallery.jsx +++ b/src/editors/sharedComponents/SelectionModal/Gallery.jsx @@ -1,9 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { - Scrollable, Spinner, -} from '@openedx/paragon'; +import { Spinner } from '@openedx/paragon'; import { FormattedMessage, useIntl, @@ -59,26 +57,24 @@ export const Gallery = ({ ); } return ( - -
- - { displayList.map(asset => ( - - )) } - -
-
+
+ + { displayList.map(asset => ( + + )) } + +
); }; diff --git a/src/editors/sharedComponents/SelectionModal/index.jsx b/src/editors/sharedComponents/SelectionModal/index.jsx index 9d37e2a60..c7c77e75a 100644 --- a/src/editors/sharedComponents/SelectionModal/index.jsx +++ b/src/editors/sharedComponents/SelectionModal/index.jsx @@ -81,7 +81,7 @@ export const SelectionModal = ({ )} title={intl.formatMessage(titleMsg)} - bodyStyle={{ background, padding: '3px 24px' }} + bodyStyle={{ background }} headerComponent={(
diff --git a/src/editors/sharedComponents/SelectionModal/index.scss b/src/editors/sharedComponents/SelectionModal/index.scss index 8e3225945..50fbd29c5 100644 --- a/src/editors/sharedComponents/SelectionModal/index.scss +++ b/src/editors/sharedComponents/SelectionModal/index.scss @@ -21,7 +21,7 @@ } /* Set top padding to 0 when there is an alert above. */ -.selection-modal .pgn__vstack > .alert + .gallery > .pgn__scrollable-body-content > .p-4 { +.selection-modal .pgn__scrollable-body-content > .pgn__vstack > .alert + .gallery > .p-4 { padding-top: 0 !important; } diff --git a/src/editors/sharedComponents/SourceCodeModal/__snapshots__/index.test.jsx.snap b/src/editors/sharedComponents/SourceCodeModal/__snapshots__/index.test.jsx.snap index 4c3d48d69..1cce90637 100644 --- a/src/editors/sharedComponents/SourceCodeModal/__snapshots__/index.test.jsx.snap +++ b/src/editors/sharedComponents/SourceCodeModal/__snapshots__/index.test.jsx.snap @@ -2,7 +2,11 @@ exports[`SourceCodeModal renders as expected with default behavior 1`] = `
{ const { saveBtnProps, value, ref } = hooks.prepareSourceCodeModal({ editorRef, close }); + const { height } = useWindowSize(); + return ( -
+
jest.requireActual('testUtils').mockNestedCo Stack: 'Stack', Toast: 'Toast', Truncate: 'Truncate', + useWindowSize: { height: '500px' }, })); jest.mock('@openedx/paragon/icons', () => ({