Skip to content

Commit 0008f3b

Browse files
committed
fixed embedded chart double-initialization
Fixed a bug where embedded card contents would be initialized multiple times, potentially causing issues with some components (such as the chart component) when embedded in a card.
1 parent c1705a8 commit 0008f3b

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- Fixed a display bug where the table search box would disappear when scrolling horizontally in a large table.
2020
- Remove small blank padding around tables in the table component
2121
- Fixed a bug in the table component where searching for "xy" would match a row with a cell that contains "x" followed by a cell that contains "y". This should match "x y" but not "xy".
22+
- Fixed a bug where embedded card contents would be initialized multiple times, potentially causing issues with some components (such as the chart component) when embedded in a card.
2223

2324
## 0.30.1 (2024-10-31)
2425
- fix a bug where table sorting would break if table search was not also enabled.

examples/official-site/sqlpage/migrations/01_documentation.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ to the path of the file you want to include, followed by `?_sqlpage_embed`.
667667
json('[
668668
{"component":"card", "title":"A dashboard with multiple graphs on the same line", "columns": 2},
669669
{"embed": "/examples/chart.sql?color=green&n=42&_sqlpage_embed", "footer_md": "You can find the sql file that generates the chart [here](https://github.com/lovasoa/SQLpage/tree/main/examples/official-site/examples/chart.sql)" },
670-
{"embed": "/examples/chart.sql?_sqlpage_embed" },
670+
{"embed": "/examples/chart.sql?_sqlpage_embed" }
671671
]'));
672672

673673
INSERT INTO component(name, icon, description) VALUES

sqlpage/sqlpage.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ const nonce = document.currentScript.nonce;
33

44
function sqlpage_card() {
55
for (const c of document.querySelectorAll("[data-pre-init=card]")) {
6-
const source = c.dataset.embed;
6+
c.removeAttribute("data-pre-init");
77
fetch(c.dataset.embed)
88
.then((res) => res.text())
99
.then((html) => {
1010
const body = c.querySelector(".card-content");
1111
body.innerHTML = html;
12-
c.removeAttribute("data-pre-init");
1312
const spinner = c.querySelector(".card-loading-placeholder");
1413
if (spinner) {
1514
spinner.parentNode.removeChild(spinner);

0 commit comments

Comments
 (0)