Skip to content

fix(orderlist): preserve original order when moving multi-selected items#8497

Merged
melloware merged 6 commits intoprimefaces:masterfrom
Coderxrohan:fix/orderlist-multiselect-order
Feb 4, 2026
Merged

fix(orderlist): preserve original order when moving multi-selected items#8497
melloware merged 6 commits intoprimefaces:masterfrom
Coderxrohan:fix/orderlist-multiselect-order

Conversation

@Coderxrohan
Copy link
Contributor

@Coderxrohan Coderxrohan commented Feb 4, 2026

Defect Fix

This PR addresses a multi-selection ordering issue in OrderList where items selected out of sequence (e.g., Ctrl-click) were reordered incorrectly when moved to the top or bottom.

Summary of changes:

Normalize multi-selection by sorting selected items based on their original list index before reorder operations.
Ensures selected items always retain their visual order regardless of selection sequence.

Notes

This is a focused UX bug fix with no API changes.
Only components/orderlist/OrderList.js is affected.
Behavior now matches user expectations and native list reordering patterns.

Fixes: #8496
Fixed:#8496
Fixes: #8495
Fixed:#8495

(Duplicate due to ci error)

@github-actions
Copy link

github-actions bot commented Feb 4, 2026

Thanks a lot for your contribution! But, PR does not seem to be linked to any issues. Please manually link to an issue or mention it in the description using #<issue_id>.

2 similar comments
@github-actions
Copy link

github-actions bot commented Feb 4, 2026

Thanks a lot for your contribution! But, PR does not seem to be linked to any issues. Please manually link to an issue or mention it in the description using #<issue_id>.

@github-actions
Copy link

github-actions bot commented Feb 4, 2026

Thanks a lot for your contribution! But, PR does not seem to be linked to any issues. Please manually link to an issue or mention it in the description using #<issue_id>.

@Coderxrohan Coderxrohan force-pushed the fix/orderlist-multiselect-order branch from bd667c8 to e0b5e6e Compare February 4, 2026 14:02
@Coderxrohan
Copy link
Contributor Author

Coderxrohan commented Feb 4, 2026

Fixed:

8497.mp4

@Coderxrohan
Copy link
Contributor Author

Coderxrohan commented Feb 4, 2026

Hi @melloware,
I’ve opened a PR that normalizes multi-selection order in OrderList.
This resolves both issues where selecting items out of sequence breaks

  1. Up/Down (Cannot reorder multi-selected items under specific condition #8495) and
  2. reverses Top/Bottom (Wrong order after moving multiple-selected items to top or bottom under specific conditions #8496).

The fix simply sorts selected items by their original list index before reorder actions — no API changes.
Would appreciate your review when you have time. Thanks!

@Coderxrohan
Copy link
Contributor Author

/assign me

@Coderxrohan
Copy link
Contributor Author

Coderxrohan commented Feb 4, 2026

@melloware, ready to merge!
Both changes were verified locally and are now fixed.

if (metaKey) {
const merged = [...selectionState, value];

newSelection = merged.sort((a, b) => props.value.indexOf(a) - props.value.indexOf(b));
Copy link
Member

Choose a reason for hiding this comment

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

SHould we check if props.value is not undefined or null or else this will error? I didn't look at the rest of the code so not sure its even possible

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested changes applied. Please take a look. Thanks!

@Coderxrohan
Copy link
Contributor Author

Coderxrohan commented Feb 4, 2026

Added a small defensive fallback for props.value to avoid potential null/undefined during sort.
Pushed the update,
Thanks!

@melloware melloware merged commit fc9c8d4 into primefaces:master Feb 4, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants