@bobfrankston/rmfmail 1.0.652 → 1.0.654

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client/app.js CHANGED
@@ -2823,21 +2823,54 @@ viewBtn?.addEventListener("click", (e) => {
2823
2823
  if (viewDropdown)
2824
2824
  viewDropdown.hidden = !viewDropdown.hidden;
2825
2825
  });
2826
- document.addEventListener("click", (e) => {
2827
- // Only close when the click is genuinely outside the menu container.
2828
- // The earlier unconditional close had two problems: clicks on radio
2829
- // buttons / checkboxes INSIDE the menu also closed it (so the user
2830
- // couldn't toggle anything without reopening), and any handler
2831
- // upstream that consumed the event (preventDefault paths, focus
2832
- // shifts) could keep the menu open inappropriately. The closest()
2833
- // check ensures inside-clicks pass through and outside-clicks close.
2826
+ // Capture-phase pointerdown so we run BEFORE any handler that calls
2827
+ // stopPropagation. The earlier bubble-phase click listener missed clicks
2828
+ // when an upstream handler swallowed propagation, and the menu stayed open.
2829
+ // pointerdown also feels snappier than waiting for click (which fires on
2830
+ // pointerup). The closest() checks let inside-clicks (radio buttons,
2831
+ // checkboxes, the input) keep the menu open.
2832
+ document.addEventListener("pointerdown", (e) => {
2834
2833
  const target = e.target;
2835
- if (viewDropdown && !viewDropdown.hidden && !target?.closest("#view-menu") && !target?.closest("#view-dropdown")) {
2834
+ if (!target)
2835
+ return;
2836
+ // Don't close if the click is on the toolbar button that toggles us —
2837
+ // its own handler will run after this and toggle, otherwise we'd
2838
+ // close-then-reopen-then-close.
2839
+ if (target.closest("#btn-view, #btn-settings, #rail-view, #rail-settings, #rail-menu-backdrop"))
2840
+ return;
2841
+ if (viewDropdown && !viewDropdown.hidden && !target.closest("#view-menu") && !target.closest("#view-dropdown")) {
2836
2842
  viewDropdown.hidden = true;
2837
2843
  }
2838
- if (settingsDropdown && !settingsDropdown.hidden && !target?.closest("#settings-menu") && !target?.closest("#settings-dropdown")) {
2844
+ if (settingsDropdown && !settingsDropdown.hidden && !target.closest("#settings-menu") && !target.closest("#settings-dropdown")) {
2839
2845
  settingsDropdown.hidden = true;
2840
2846
  }
2847
+ }, true);
2848
+ // Escape always closes any open dropdown/backdrop, regardless of how it was
2849
+ // opened or whether an outside-click handler missed firing. Last-resort
2850
+ // escape hatch for the "stuck modal" case.
2851
+ document.addEventListener("keydown", (e) => {
2852
+ if (e.key !== "Escape")
2853
+ return;
2854
+ let closed = false;
2855
+ for (const id of ["settings-dropdown", "view-dropdown", "restart-dropdown"]) {
2856
+ const dd = document.getElementById(id);
2857
+ if (dd && !dd.hidden) {
2858
+ dd.hidden = true;
2859
+ closed = true;
2860
+ }
2861
+ }
2862
+ const bd = document.getElementById("rail-menu-backdrop");
2863
+ if (bd) {
2864
+ bd.remove();
2865
+ closed = true;
2866
+ }
2867
+ const themeSub = document.getElementById("theme-submenu");
2868
+ if (themeSub && !themeSub.hidden) {
2869
+ themeSub.hidden = true;
2870
+ closed = true;
2871
+ }
2872
+ if (closed)
2873
+ e.preventDefault();
2841
2874
  });
2842
2875
  // Restore saved view settings
2843
2876
  const savedTwoLine = localStorage.getItem("mailx-two-line") === "true";