@gradio/tabs 0.5.10 → 0.5.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @gradio/tabs
2
2
 
3
+ ## 0.5.11
4
+
5
+ ### Fixes
6
+
7
+ - [#13240](https://github.com/gradio-app/gradio/pull/13240) [`0d670ad`](https://github.com/gradio-app/gradio/commit/0d670adf41a0b510f7fd745495dce1664d38f0e5) - Fix browser freeze when a dataframe's value is set (e.g. via a tab select event), and only dispatch the tabs select event when the selected tab actually changes. Thanks @freddyaboulton!
8
+
3
9
  ## 0.5.10
4
10
 
5
11
  ### Fixes
package/Index.svelte CHANGED
@@ -7,24 +7,26 @@
7
7
  import Tabs from "./shared/Tabs.svelte";
8
8
  import Walkthrough from "./shared/Walkthrough.svelte";
9
9
  import type { TabsProps, TabsEvents } from "./types";
10
- import { untrack } from "svelte";
11
10
 
12
11
  let props = $props();
13
12
  const gradio = new Gradio<TabsEvents, TabsProps>(props);
14
13
 
14
+ let old_selected = gradio.props.selected;
15
+
15
16
  $effect(() => {
16
- if (gradio.props.selected) {
17
- untrack(() => {
18
- const i = gradio.props.initial_tabs.findIndex(
19
- (t) => t.id === gradio.props.selected
20
- );
17
+ if (old_selected !== gradio.props.selected) {
18
+ const i = gradio.props.initial_tabs.findIndex(
19
+ (t) => t.id === gradio.props.selected
20
+ );
21
+ if (i >= 0) {
21
22
  gradio.dispatch("gradio_tab_select", {
22
23
  value: gradio.props.initial_tabs[i].label,
23
24
  index: i,
24
25
  id: gradio.props.initial_tabs[i].id,
25
26
  component_id: gradio.props.initial_tabs[i].component_id
26
27
  });
27
- });
28
+ }
29
+ old_selected = gradio.props.selected;
28
30
  }
29
31
  });
30
32
  </script>
package/dist/Index.svelte CHANGED
@@ -7,24 +7,26 @@
7
7
  import Tabs from "./shared/Tabs.svelte";
8
8
  import Walkthrough from "./shared/Walkthrough.svelte";
9
9
  import type { TabsProps, TabsEvents } from "./types";
10
- import { untrack } from "svelte";
11
10
 
12
11
  let props = $props();
13
12
  const gradio = new Gradio<TabsEvents, TabsProps>(props);
14
13
 
14
+ let old_selected = gradio.props.selected;
15
+
15
16
  $effect(() => {
16
- if (gradio.props.selected) {
17
- untrack(() => {
18
- const i = gradio.props.initial_tabs.findIndex(
19
- (t) => t.id === gradio.props.selected
20
- );
17
+ if (old_selected !== gradio.props.selected) {
18
+ const i = gradio.props.initial_tabs.findIndex(
19
+ (t) => t.id === gradio.props.selected
20
+ );
21
+ if (i >= 0) {
21
22
  gradio.dispatch("gradio_tab_select", {
22
23
  value: gradio.props.initial_tabs[i].label,
23
24
  index: i,
24
25
  id: gradio.props.initial_tabs[i].id,
25
26
  component_id: gradio.props.initial_tabs[i].component_id
26
27
  });
27
- });
28
+ }
29
+ old_selected = gradio.props.selected;
28
30
  }
29
31
  });
30
32
  </script>
@@ -37,16 +37,20 @@
37
37
 
38
38
  // When initial_tabs changes (e.g. a non-mounted tab's props were updated),
39
39
  // sync the internal tabs array so the tab buttons reflect the new state.
40
- // Using a function call so the $: dependency is only on initial_tabs,
41
- // not on tabs (which would cause a loop with register_tab).
40
+ // The tabs mutation is deferred via tick() because in Svelte 5 legacy mode
41
+ // $: effects track all reads inside called functions writing tabs[i]
42
+ // through the $state proxy would track `tabs` as a dependency, creating
43
+ // an infinite self-triggering loop.
42
44
  $: _sync_tabs(initial_tabs);
43
45
 
44
46
  function _sync_tabs(new_tabs: Tab[]): void {
45
- for (let i = 0; i < new_tabs.length; i++) {
46
- if (new_tabs[i] && !mounted_tab_orders.has(i)) {
47
- tabs[i] = new_tabs[i];
47
+ tick().then(() => {
48
+ for (let i = 0; i < new_tabs.length; i++) {
49
+ if (new_tabs[i] && !mounted_tab_orders.has(i)) {
50
+ tabs[i] = new_tabs[i];
51
+ }
48
52
  }
49
- }
53
+ });
50
54
  }
51
55
 
52
56
  $: has_tabs = tabs.length > 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradio/tabs",
3
- "version": "0.5.10",
3
+ "version": "0.5.11",
4
4
  "description": "Gradio UI packages",
5
5
  "type": "module",
6
6
  "author": "",
@@ -37,16 +37,20 @@
37
37
 
38
38
  // When initial_tabs changes (e.g. a non-mounted tab's props were updated),
39
39
  // sync the internal tabs array so the tab buttons reflect the new state.
40
- // Using a function call so the $: dependency is only on initial_tabs,
41
- // not on tabs (which would cause a loop with register_tab).
40
+ // The tabs mutation is deferred via tick() because in Svelte 5 legacy mode
41
+ // $: effects track all reads inside called functions writing tabs[i]
42
+ // through the $state proxy would track `tabs` as a dependency, creating
43
+ // an infinite self-triggering loop.
42
44
  $: _sync_tabs(initial_tabs);
43
45
 
44
46
  function _sync_tabs(new_tabs: Tab[]): void {
45
- for (let i = 0; i < new_tabs.length; i++) {
46
- if (new_tabs[i] && !mounted_tab_orders.has(i)) {
47
- tabs[i] = new_tabs[i];
47
+ tick().then(() => {
48
+ for (let i = 0; i < new_tabs.length; i++) {
49
+ if (new_tabs[i] && !mounted_tab_orders.has(i)) {
50
+ tabs[i] = new_tabs[i];
51
+ }
48
52
  }
49
- }
53
+ });
50
54
  }
51
55
 
52
56
  $: has_tabs = tabs.length > 0;