Skip to content

Commit

Permalink
fix: sort labels
Browse files Browse the repository at this point in the history
  • Loading branch information
moshloop committed Sep 17, 2021
1 parent 3fcac39 commit afd1855
Showing 1 changed file with 27 additions and 15 deletions.
42 changes: 27 additions & 15 deletions src/components/Canary/FilterForm/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,33 @@ export function FilterForm({ labels, checks, history }) {
<div className="uppercase font-semibold text-sm mb-3 text-indigo-700">
Filter By Label
</div>
{Object.values(labels).map((label) => (
<Controller
key={label.id}
name={`labels.${label.id}`}
control={control}
render={({ field: { ref, ...rest } }) => (
<TristateToggle
key={label.key}
className="mb-2"
label={label}
{...rest}
/>
)}
/>
))}
{Object.values(labels)
.sort((a, b) => {
let _a = a.key.toLowerCase()
let _b = b.key.toLowerCase()
if (_a < _b) {
return -1
}
if (_a > b) {
return 1
}
return 0
})
.map((label) => (
<Controller
key={label.id}
name={`labels.${label.id}`}
control={control}
render={({ field: { ref, ...rest } }) => (
<TristateToggle
key={label.key}
className="mb-2"
label={label}
{...rest}
/>
)}
/>
))}
</div>
</form>
);
Expand Down

0 comments on commit afd1855

Please sign in to comment.