@snack-uikit/segmented-control 0.2.4-preview-e5174ad1.0 → 0.2.5-preview-71543426.0

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
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 0.2.4 (2024-10-16)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **PDS-881:** update selection position when items changed ([9d89cb9](https://github.com/cloud-ru-tech/snack-uikit/commit/9d89cb960959d46aa1cfdda0a2fc6999d8c49608))
12
+
13
+
14
+
15
+
16
+
6
17
  ## 0.2.3 (2024-09-26)
7
18
 
8
19
  ### Only dependencies have been changed
@@ -74,7 +74,14 @@ function SegmentedControl(_a) {
74
74
  }
75
75
  const observer = new ResizeObserver(() => updateSelectionPosition());
76
76
  observer.observe(containerRef.current);
77
- return () => observer.disconnect();
77
+ const ob = new MutationObserver(() => updateSelectionPosition());
78
+ ob.observe(containerRef.current, {
79
+ childList: true
80
+ });
81
+ return () => {
82
+ observer.disconnect();
83
+ ob.disconnect();
84
+ };
78
85
  }, [updateSelectionPosition]);
79
86
  const itemsJSX = (0, react_1.useMemo)(() => items.map(props => (0, jsx_runtime_1.jsx)("div", {
80
87
  className: styles_module_scss_1.default.segmentHolder,
@@ -48,7 +48,14 @@ export function SegmentedControl(_a) {
48
48
  }
49
49
  const observer = new ResizeObserver(() => updateSelectionPosition());
50
50
  observer.observe(containerRef.current);
51
- return () => observer.disconnect();
51
+ const ob = new MutationObserver(() => updateSelectionPosition());
52
+ ob.observe(containerRef.current, {
53
+ childList: true,
54
+ });
55
+ return () => {
56
+ observer.disconnect();
57
+ ob.disconnect();
58
+ };
52
59
  }, [updateSelectionPosition]);
53
60
  const itemsJSX = useMemo(() => items.map(props => (_jsx("div", { className: styles.segmentHolder, "data-width": width, children: _jsx(Segment, Object.assign({}, props, { size: size, onGetFocusable: onGetFocusable, selected: selected === props.value, onClick: () => setSelected(props.value), focusable: focusableSegmentValue === props.value, onSelectionUpdated: updateSelectionPosition })) }, props.value))), [items, width, size, onGetFocusable, selected, focusableSegmentValue, updateSelectionPosition, setSelected]);
54
61
  return (
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Segmented Control",
7
- "version": "0.2.4-preview-e5174ad1.0",
7
+ "version": "0.2.5-preview-71543426.0",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -34,10 +34,10 @@
34
34
  "license": "Apache-2.0",
35
35
  "scripts": {},
36
36
  "dependencies": {
37
- "@snack-uikit/truncate-string": "0.4.25-preview-e5174ad1.0",
38
- "@snack-uikit/utils": "3.4.1-preview-e5174ad1.0",
37
+ "@snack-uikit/truncate-string": "0.4.25-preview-71543426.0",
38
+ "@snack-uikit/utils": "3.4.1-preview-71543426.0",
39
39
  "classnames": "2.5.1",
40
40
  "uncontrollable": "8.0.4"
41
41
  },
42
- "gitHead": "3e1b0165a7ffe4fec49e268ad4c171ec97385243"
42
+ "gitHead": "3102614275e261c8f41db0f6c00a1f6b6276b2a9"
43
43
  }
@@ -86,7 +86,16 @@ export function SegmentedControl<Value extends IdType>({
86
86
 
87
87
  const observer = new ResizeObserver(() => updateSelectionPosition());
88
88
  observer.observe(containerRef.current);
89
- return () => observer.disconnect();
89
+
90
+ const ob = new MutationObserver(() => updateSelectionPosition());
91
+ ob.observe(containerRef.current, {
92
+ childList: true,
93
+ });
94
+
95
+ return () => {
96
+ observer.disconnect();
97
+ ob.disconnect();
98
+ };
90
99
  }, [updateSelectionPosition]);
91
100
 
92
101
  const itemsJSX = useMemo(