@bobfrankston/rmfmail 1.1.216 → 1.1.217

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.
@@ -2736,19 +2736,30 @@ function currentViewKey() {
2736
2736
  }
2737
2737
  function withScrollAnchor(body, doRender) {
2738
2738
  const scrollTop = body.scrollTop;
2739
- if (scrollTop < 4) {
2740
- doRender();
2741
- return;
2742
- }
2743
- const rowsBefore = Array.from(body.querySelectorAll(".ml-row"));
2739
+ const viewportH = body.clientHeight;
2744
2740
  let anchorUuid = "";
2745
2741
  let anchorOffsetWithinViewport = 0;
2746
- for (const r of rowsBefore) {
2747
- const visualTop = r.offsetTop - scrollTop;
2748
- if (visualTop >= 0) {
2749
- anchorUuid = r.dataset.uuid || "";
2750
- anchorOffsetWithinViewport = visualTop;
2751
- break;
2742
+ const selected = body.querySelector(".ml-row.selected");
2743
+ if (selected) {
2744
+ const vt = selected.offsetTop - scrollTop;
2745
+ if (vt > -selected.offsetHeight && vt < viewportH) {
2746
+ anchorUuid = selected.dataset.uuid || "";
2747
+ anchorOffsetWithinViewport = vt;
2748
+ }
2749
+ }
2750
+ if (!anchorUuid) {
2751
+ if (scrollTop < 4) {
2752
+ doRender();
2753
+ return;
2754
+ }
2755
+ const rowsBefore = Array.from(body.querySelectorAll(".ml-row"));
2756
+ for (const r of rowsBefore) {
2757
+ const visualTop = r.offsetTop - scrollTop;
2758
+ if (visualTop >= 0) {
2759
+ anchorUuid = r.dataset.uuid || "";
2760
+ anchorOffsetWithinViewport = visualTop;
2761
+ break;
2762
+ }
2752
2763
  }
2753
2764
  }
2754
2765
  doRender();