diff --git a/datasette/static/table.js b/datasette/static/table.js index a5f21979..ffa5e254 100644 --- a/datasette/static/table.js +++ b/datasette/static/table.js @@ -44,8 +44,19 @@ var DROPDOWN_ICON_SVG = ` { + /* was this click outside the menu? */ + var target = ev.target; + while (target && target != menu) { + target = target.parentNode; + } + if (!target) { + menu.style.display = 'none'; + } + }); function iconClicked(ev) { ev.preventDefault(); + ev.stopPropagation(); var th = ev.target; while (th.nodeName != 'TH') { th = th.parentNode; @@ -91,9 +102,9 @@ var DROPDOWN_ICON_SVG = `