pagedown icon indicating copy to clipboard operation
pagedown copied to clipboard

Last rows of long tables are hidden

Open dsvanidze opened this issue 7 months ago • 1 comments

Hi,

I use pagedown 0.16.1 and have a number of long tables that extend over several pages. I have noticed that pagedown renders last rows on each table, but they are not visible (see the current output). Update to pagedown 0.20 did not solve the issue. I would expect that the last rows of a long table should be visible on every page, or if they go over the boundaries, they should move to the next page and not just be hidden (see screenshots).

Current output: current-output

Expected output: expected-output

I found a workaround that produces the expected output (makes the last row visible), but it would be great if there is a better solution or if the bug is fixed.

const intervalID = setInterval(() => {
  // Wait until Paged.js is loaded and then remove the interval
  if (Paged) {
    clearInterval(intervalID);
  } else {
    return;
  }

  class MyHandler extends Paged.Handler {
    constructor(chunker, polisher, caller) {
      super(chunker, polisher, caller);
    }

    afterPreview() {
      // This is the main part to fix the bug with "column-width": "auto"
      Array.from(
        document.getElementsByClassName("pagedjs_page_content")
      ).forEach((el) => {
        el.style.columnWidth = "auto";
      });
    }
  }

  Paged.registerHandlers(MyHandler);
}, 20);

Here is the R code to reproduce the long table:

data.table(count = factor(1:120)) %>%
  tbl_summary() %>%
  bold_labels() %>%
  as_kable_extra(escape = TRUE)
### Tasks

dsvanidze avatar Nov 21 '23 14:11 dsvanidze