From ca096c7a64b5098ac1548d0996e871f63934b7ae Mon Sep 17 00:00:00 2001 From: Florrie Date: Thu, 9 Jul 2020 17:09:02 -0300 Subject: don't show a divider as the first item in a menu --- ui.js | 10 ++++++++-- 1 file 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 -- cgit 1.3.0-6-gf8a5