diff options
author | Florrie <towerofnix@gmail.com> | 2020-07-09 17:09:02 -0300 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2020-07-09 17:09:02 -0300 |
commit | a8bebdac05d6857eff5c87ab63e44edddcbb148a (patch) | |
tree | e3912ad03208b23ebcbece37f6c686a9d8a4c8a4 | |
parent | 71dd9675e8ceef415eb629895e1abe90eca2e2f0 (diff) |
don't show a divider as the first item in a menu
-rw-r--r-- | ui.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/ui.js b/ui.js index f333b7a..0499ff6 100644 --- a/ui.js +++ b/ui.js @@ -3836,12 +3836,16 @@ class ContextMenu extends FocusElement { let wantDivider = false const addDividerIfWanted = () => { if (wantDivider) { - const element = new HorizontalRule() - this.form.addInput(element) + if (!firstItem) { + const element = new HorizontalRule() + this.form.addInput(element) + } wantDivider = false } } + let firstItem = true + const keyElementMap = {} for (const item of items.filter(Boolean)) { @@ -3854,6 +3858,7 @@ class ContextMenu extends FocusElement { if (item.isDefault) { this.root.select(item.element) } + firstItem = false } else if (item.divider) { wantDivider = true } else { @@ -3875,6 +3880,7 @@ class ContextMenu extends FocusElement { if (item.isDefault) { this.root.select(button) } + firstItem = false } if (item.key) { keyElementMap[item.key] = focusEl |