Skip to content

SortableGridList - Order items by index #3171

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

Merged
merged 17 commits into from
Jul 31, 2024

Conversation

nitzanyiz
Copy link
Collaborator

@nitzanyiz nitzanyiz commented Jul 10, 2024

Description

Added option for SortableGridList to reorder the items by their index (instead of by replacing locations).

Changelog

SortableGridList - New prop orderByIndex. adds support for reordering by index.

Additional info

MADS-4277

@nitzanyiz nitzanyiz marked this pull request as ready for review July 14, 2024 09:57
@nitzanyiz nitzanyiz changed the title Feat/sortabe grid list re order by index SortableGridList - Order items by index Jul 14, 2024
@nitzanyiz nitzanyiz requested review from M-i-k-e-l and removed request for ethanshar July 14, 2024 12:55
@nitzanyiz nitzanyiz assigned M-i-k-e-l and unassigned ethanshar Jul 14, 2024
const onOrderChange = jest.fn();
const renderTree = render(<Testcase onOrderChange={onOrderChange} orderItemsByIndex/>);
const driverItem = useDraggableDriver(useComponentDriver({renderTree, testID: itemsTestId('0')}));
driverItem.drag(150); // Items height is 50 but dragging 100 doesn't work for some reason. 150 works and drags one row down.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to create a driver

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what the calculation for the drag is. I used 150 because it worked but I don't know If I can make a driver that will be correct for all cases.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can look at SortableListItem.driver.new.ts; even if it's not perfect, it's better than nothing

Copy link
Collaborator Author

@nitzanyiz nitzanyiz Jul 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the SortableListItem we have a default height for the items so its easy to calculate. Also the widths here are calculated based on the props. I don't really think we need to invest much time in this currently tbh. We can come back to this some other time.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You've added tests, so it seems logical to add a driver...
We will probably never have time to refactor this...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll probably get to this if the component is used more

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you intent to measure usage?

Copy link
Collaborator Author

@nitzanyiz nitzanyiz Jul 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Channel bugs and questions i guess

@M-i-k-e-l M-i-k-e-l assigned nitzanyiz and unassigned M-i-k-e-l Jul 23, 2024
@nitzanyiz nitzanyiz assigned M-i-k-e-l and unassigned nitzanyiz Jul 24, 2024
@ethanshar ethanshar added the Important for Next Release PR that must be included in the release version label Jul 28, 2024
@nitzanyiz nitzanyiz assigned nitzanyiz and unassigned nitzanyiz and M-i-k-e-l Jul 30, 2024
@nitzanyiz nitzanyiz assigned M-i-k-e-l and unassigned nitzanyiz Jul 30, 2024
@M-i-k-e-l M-i-k-e-l assigned nitzanyiz and unassigned M-i-k-e-l Jul 30, 2024
@nitzanyiz nitzanyiz assigned M-i-k-e-l and unassigned nitzanyiz Jul 30, 2024
const onOrderChange = jest.fn();
const renderTree = render(<TestCase onOrderChange={onOrderChange} orderByIndex/>);
const driverItem = useDraggableDriver(useComponentDriver({renderTree, testID: itemsTestId('0')}));
driverItem.drag(150); // Items height is 50 but dragging 100 doesn't work for some reason. 150 works and drags one row down.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drag(300) also "works" - any idea why?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No 🤷🏻‍♂️

@M-i-k-e-l M-i-k-e-l assigned nitzanyiz and unassigned M-i-k-e-l Jul 30, 2024
@nitzanyiz nitzanyiz assigned M-i-k-e-l and unassigned nitzanyiz Jul 31, 2024
@M-i-k-e-l M-i-k-e-l assigned nitzanyiz and unassigned M-i-k-e-l Jul 31, 2024
@nitzanyiz nitzanyiz merged commit dfdb5f5 into master Jul 31, 2024
1 check passed
@nitzanyiz nitzanyiz deleted the feat/SortabeGridListReOrderByIndex branch July 31, 2024 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Important for Next Release PR that must be included in the release version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants