Skip to content

Commit

Permalink
prevent runaway row loading
Browse files Browse the repository at this point in the history
  • Loading branch information
maccesch committed Feb 20, 2024
1 parent 9d1ad1b commit 1da8ee0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [0.8.3] - 2024-02-20

### Fix 🐛

- When not limiting a scroll container this could lead to a runaway row loading. This is now limited to max 500 rows.

## [0.8.2] - 2024-02-18

### Feature 🚀
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "leptos-struct-table"
version = "0.8.2"
version = "0.8.3"
edition = "2021"
authors = ["Marc-Stefan Cassola"]
categories = ["gui", "web-programming"]
Expand Down
4 changes: 4 additions & 0 deletions src/components/table_content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ use std::rc::Rc;
use wasm_bindgen::JsCast;
use web_sys::Element;

const MAX_DISPLAY_ROW_COUNT: usize = 500;

renderer_fn!(
RowRendererFn<Row>(
class: Signal<String>,
Expand Down Expand Up @@ -368,6 +370,8 @@ where
end = end.min(row_count);
}

end = end.min(start + MAX_DISPLAY_ROW_COUNT);

loaded_rows.update_untracked(|loaded_rows| {
if end > loaded_rows.len() {
loaded_rows.resize(end);
Expand Down

0 comments on commit 1da8ee0

Please sign in to comment.