Skip to content

Commit

Permalink
Do not apply reordering for empty orders (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
elchininet authored Jan 3, 2024
1 parent 6109183 commit 530cd24
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Custom [HACS] plugin that allows you to rearrange, hide, and add menu items to t
</tr>
</table>

This is a refactor of [custom-sidebar-v2] by @galloween, which is now archived. Inspired in the [original Custom Sidebar] plugin by @Villhellm (R.I.P).
This is a refactor of [custom-sidebar-v2] by @galloween, which is now archived. Inspired in the [original Custom Sidebar] plugin by @Villhellm (R.I.P.).

## Installation

Expand Down Expand Up @@ -125,6 +125,7 @@ Short example:
* All items in config.order should have unique `item` property
* The items will be ordered according to their `order` property OR in the order of appearance
* If you use the `order` property, make sure either all items (except hidden ones) have this property, or none of them (otherwise order may be messed up)
* All the items placed in the bottom will be moved to the top by default. If you want to have some items in the bottom you need to add them to the `config.order` and specify their `bottom` property on `true`.
* Any items present in the Sidebar, but not in `config.order`, will be shown **on the bottom** of the top part of the list
* Notifications and user account are not part of the sidebar items; it will not be processed

Expand Down Expand Up @@ -204,7 +205,7 @@ Then you can modify them as the regular ones:

## Credits

* [Villhellm](https://github.com/Villhellm/custom-sidebar) | Original creator of custom-sidebar (R.I.P).
* [Villhellm](https://github.com/Villhellm/custom-sidebar) | Original creator of custom-sidebar (R.I.P.).
* [galloween](https://github.com/galloween) | forked the `original custom-sidebar` and maintained it for a while

[HACS]: https://hacs.xyz
Expand Down
2 changes: 2 additions & 0 deletions src/custom-sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ class CustomSidebar {
let orderIndex = 0;
let crossedBottom = false;

if (!order.length) return;

const orderWithItems: ConfigOrderWithItem[] = order.map((orderItem: ConfigOrder): ConfigOrderWithItem => {
const { item, new_item, exact } = orderItem;
const itemLowerCase = item.toLocaleLowerCase();
Expand Down

0 comments on commit 530cd24

Please sign in to comment.