inveniosoftware / react-searchkit

React component library for interacting with a REST API.
https://inveniosoftware.github.io/react-searchkit/
MIT License
78 stars 40 forks source link

Facets that start with the same characters #85

Open topless opened 4 years ago

topless commented 4 years ago

When there are facets that start with the same name they cannot be both selected.

tags-bug

ntarocco commented 4 years ago

The solution might not be easy, I can give more context for who will work on it.

Here the test to add and reproduce the issue (Publication and Publicatio):

test('query with very similar query values.', () => {
    const state = [['file_type', 'pdf'], ['type', 'Publication']];
    const query = ['type', 'Publicatio'];

    const newState = updateQueryFilters(query, state);

    expect(newState).toEqual([
      ['file_type', 'pdf'],
      ['type', 'Publication'],
      ['type', 'Publicatio'],
    ]);

    const state2 = [['file_type', 'pdf'], ['type', 'Publicatio']];
    const query2 = ['type', 'Publication'];

    const newState2 = updateQueryFilters(query2, state2);

    expect(newState2).toEqual([
      ['file_type', 'pdf'],
      ['type', 'Publication'],
      ['type', 'Publicatio'],
    ]);
  });