-
Notifications
You must be signed in to change notification settings - Fork 3.2k
feat(ui) Add drag and drop functionality to modules on home page #14100
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
Conversation
Bundle ReportChanges will increase total bundle size by 49.53kB (0.22%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: datahub-react-web-esmAssets Changed:
Files in
|
✅ Meticulous spotted 0 visual differences across 1589 screens tested: view results. Meticulous evaluated ~9 hours of user flows against your PR. Expected differences? Click here. Last updated for commit eb9915c. This comment will update as new commits are pushed. |
5d047ae
to
5988dd8
Compare
be15f62
to
0ef8415
Compare
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.
beauty
if (!template) return null; | ||
|
||
const { rowIndex: toRowIndex } = toPosition; | ||
if (toRowIndex === undefined) { |
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.
when would this happen?
@@ -85,3 +107,6 @@ export default function LargeModule({ children, module, loading, onClickViewAll | |||
</ModuleContainer> | |||
); | |||
} | |||
|
|||
// Export memoized component to prevent unnecessary re-renders | |||
export default memo(LargeModule); |
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.
nice
insertNewRow?: boolean; | ||
} | ||
|
||
function NewRowDropZoneComponent({ rowIndex, insertNewRow = false }: Props) { |
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.
can guess for this one, but comments for many of these sub components describing where & how they're used / expected behavior could be helpful longer term
import TemplateRow from '@app/homeV3/templateRow/TemplateRow'; | ||
import { WrappedRow } from '@app/homeV3/templateRow/types'; | ||
|
||
// import NewRowDropZone from './NewRowDropZone'; |
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.
delete?
const { active } = useDndContext(); | ||
|
||
return useMemo(() => { | ||
const activeDragData = active?.data?.current as { position?: ModulePositionInput } | undefined; |
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.
is there a way to avoid cast here?
…ows of 3. looks ugly though
2ca1df7
to
eb9915c
Compare
This PR adds the ability to drag and drop modules between rows, within rows, and to new rows. The functionality utilizes a well known library that's already being used in our SaaS product, so it is still consistent.
Leverage the existing page module context in order to
moveModule
and save the state of the template and save the correct template on the backend as well. This works with the same logic for updating templates as is with other edits to modules like adding or removing them.There's a good amount of refactoring here to factor in the drag and drop context and logic. It's pretty complicated stuff so I tried to modularize it and break it down into readable functions as much as possible.
Note: a huge part of the diff is yarn lock changes and tests
Screen.Recording.2025-07-16.at.7.09.37.PM.1.mov