oklas/react-breadcrumbs-dynamic

Sorting algorithm

zmeecer opened this issue · 5 comments

Hi!
As I understand all breadcrumbs items are sorted by pathname by the following function:
https://github.com/oklas/react-breadcrumbs-dynamic/blob/master/src/index.js#L47

So it's not so easy to control order of breadcrumbs item in the Container component. In my case it is necessary for adding routes with absolute links. Something like weight parameter

I will be glad to make a new PR after your agreement

oklas commented

Hi!
It need to do in like this:

  • write commit with a tests which check the sorting as currently is
  • add user-defined function in compare property of Breadcrumbs component
  • make sorted data array of values intead of array of keys for user func at mentioned line
  • sorting must be performed by user defined function or by default function if not specified
  • write a tests with user defined function

So if users need to sort by any other criteria included analize some additional
breadcrumbs item property will be possible to do id as desired.

It will be excellent if you have time to do that or let me know if you busy then i will do that nearest days.

oklas commented

I checked just now, current sorting is already checked in tests. So, the first step is not needed.

Thanks for the quick and detailed response!

I have some time, so I will try to implement in time

It will be fair because I use your library

review, please
#20

oklas commented

Vesrion 1.1.1 is published. Thanks, people will appreciate this feature.