Skip to content
This repository was archived by the owner on May 17, 2018. It is now read-only.
This repository was archived by the owner on May 17, 2018. It is now read-only.

setSorting doesn't properly overwrite/remove comparator for client collections #108

@toekneestuck

Description

@toekneestuck

Currently at the end of the setSorting function, this is happening:

if (delComp) delete this.comparator;
if (delFullComp && fullCollection) delete fullCollection.comparator;

However, this doesn't work as expected if a default comparator is defined on the collection. Instead, it will fallback to inheriting the default comparator, which has interesting results (and could be desirable in some cases). What effectively ends up happening is a sorting of the sorted data. It will sort the fullCollection properly and then apply the default comparator to the already sorted data.

What I would propose is explicitly setting this.comparator to null when there is a sortKey present, and removing all together when there is no sortKey (which restores the 'default' sort).

if (delComp) !sortKey ? delete this.comparator : this.comparator = null;
if (delFullComp && fullCollection) !sortKey ? delete fullCollection.comparator : fullCollection.comparator = null;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions