react-multi-select icon indicating copy to clipboard operation
react-multi-select copied to clipboard

Issue #149 - It is possible to select more than maxSelectedItems when

Open yegor-babiy opened this issue 6 years ago • 8 comments

#Fixes #149

Proposed Changes

yegor-babiy avatar Jul 10 '19 11:07 yegor-babiy

@liorheber please take a look and what do you think?

yegor-babiy avatar Jul 10 '19 13:07 yegor-babiy

Sorry for the delay here. I'll be going over the PR tomorrow.

liorheber avatar Jul 16 '19 17:07 liorheber

@talyak I've been having a hard time getting to this PR. Any chance you'd be willing to take a look?

liorheber avatar Jul 30 '19 17:07 liorheber

@liorheber, @yegor-babiy - I will review it today.

talyak avatar Jul 31 '19 04:07 talyak

@yegor-babiy - why not to change the following function like this:

export const getMinMaxIndexes = ( currentIndex, firstItemShiftSelected, maxSelectedItems ) => { const range = Math.abs(firstItemShiftSelected - currentIndex) + 1; if (range > maxSelectedItems) { return firstItemShiftSelected > currentIndex ? { minIndex: firstItemShiftSelected - maxSelectedItems + 1, maxIndex: firstItemShiftSelected } : { minIndex: firstItemShiftSelected, maxIndex: firstItemShiftSelected + maxSelectedItems - 1 }; } return firstItemShiftSelected > currentIndex ? { minIndex: currentIndex, maxIndex: firstItemShiftSelected } : { minIndex: firstItemShiftSelected, maxIndex: currentIndex }; };

talyak avatar Jul 31 '19 09:07 talyak

@talyak first of all codeclimate will say that it's too complicated function with more than 5 operations and about logic in this case you don't count selected items that was selected outside range before

yegor-babiy avatar Jul 31 '19 10:07 yegor-babiy

@talyak can be merged?

yegor-babiy avatar Aug 13 '19 13:08 yegor-babiy

@liorheber @talyak guess it can be merged, I made all your recommendation

yegor-babiy avatar Aug 22 '19 08:08 yegor-babiy