Ensure paginate updates when samples value changes in Dataset (#7761)

* ensure paginate updates when samples value changes

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
Hannah 2024-03-21 15:12:34 +00:00 committed by GitHub
parent f73a9bbcd7
commit ca42748590
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 12 deletions

View File

@ -0,0 +1,6 @@
---
"@gradio/dataset": patch
"gradio": patch
---
fix:Ensure `paginate` updates when samples value changes in `Dataset`

View File

@ -51,6 +51,7 @@
}
$: {
paginate = samples.length > samples_per_page;
if (paginate) {
visible_pages = [];
selected_samples = samples.slice(
@ -83,18 +84,19 @@
async function get_component_meta(selected_samples: any[][]): Promise<void> {
component_meta = await Promise.all(
selected_samples.map(
async (sample_row) =>
await Promise.all(
sample_row.map(async (sample_cell, j) => {
return {
value: sample_cell,
component: (await component_map.get(components[j]))
?.default as ComponentType<SvelteComponent>
};
})
)
)
selected_samples &&
selected_samples.map(
async (sample_row) =>
await Promise.all(
sample_row.map(async (sample_cell, j) => {
return {
value: sample_cell,
component: (await component_map.get(components[j]))
?.default as ComponentType<SvelteComponent>
};
})
)
)
);
}