mirror of
https://github.com/gradio-app/gradio.git
synced 2025-04-06 12:30:29 +08:00
Reset Dataset
page to 0 when samples change (#9093)
* checkout * format * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
parent
6e641e2133
commit
60650d84b2
6
.changeset/petite-animals-raise.md
Normal file
6
.changeset/petite-animals-raise.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
"@gradio/dataset": patch
|
||||
"gradio": patch
|
||||
---
|
||||
|
||||
fix:Reset `Dataset` page to 0 when samples change
|
@ -14,6 +14,7 @@
|
||||
export let label = "Examples";
|
||||
export let headers: string[];
|
||||
export let samples: any[][] | null = null;
|
||||
let old_samples: any[][] | null = null;
|
||||
export let sample_labels: string[] | null = null;
|
||||
export let elem_id = "";
|
||||
export let elem_classes: string[] = [];
|
||||
@ -35,6 +36,7 @@
|
||||
? `/proxy=${proxy_url}file=`
|
||||
: `${root}/file=`;
|
||||
let page = 0;
|
||||
|
||||
$: gallery = components.length < 2 || sample_labels !== null;
|
||||
let paginate = samples ? samples.length > samples_per_page : false;
|
||||
|
||||
@ -58,6 +60,10 @@
|
||||
} else if (!samples) {
|
||||
samples = [];
|
||||
}
|
||||
if (samples !== old_samples) {
|
||||
page = 0;
|
||||
old_samples = samples;
|
||||
}
|
||||
paginate = samples.length > samples_per_page;
|
||||
if (paginate) {
|
||||
visible_pages = [];
|
||||
|
Loading…
x
Reference in New Issue
Block a user