kelt-ui-kit-react 1.9.5 → 1.9.6

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kelt-ui-kit-react",
3
3
  "type": "module",
4
- "version": "1.9.5",
4
+ "version": "1.9.6",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -67,10 +67,16 @@ export const Expand = ({
67
67
 
68
68
  useEffect(() => {
69
69
  if (active) {
70
- const timer = setTimeout(() => {
70
+ const timer1 = setTimeout(() => {
71
71
  scrollToHeader();
72
72
  }, 100);
73
- return () => clearTimeout(timer);
73
+ const timer2 = setTimeout(() => {
74
+ scrollToHeader();
75
+ }, 350);
76
+ return () => {
77
+ clearTimeout(timer1);
78
+ clearTimeout(timer2);
79
+ };
74
80
  }
75
81
  }, [active, scrollToHeader]);
76
82
 
@@ -86,47 +92,43 @@ export const Expand = ({
86
92
  const expandElement = expandRef.current;
87
93
  if (!expandElement) return;
88
94
 
89
- let scrollParent: HTMLElement | null = expandElement.parentElement;
90
- while (scrollParent) {
91
- const style = window.getComputedStyle(scrollParent);
92
- const isScrollable =
93
- /(auto|scroll)/.test(style.overflow + style.overflowY) &&
94
- scrollParent.scrollHeight > scrollParent.clientHeight;
95
-
96
- if (isScrollable) {
97
- const parentRect = scrollParent.getBoundingClientRect();
98
- const targetRect = target.getBoundingClientRect();
99
-
100
- // 1. Si l'input est déjà visible dans le conteneur, on ne scrolle pas
101
- const isVisible =
102
- targetRect.top >= parentRect.top &&
103
- targetRect.bottom <= parentRect.bottom;
104
-
105
- if (isVisible) {
106
- return;
107
- }
108
-
109
- const headerRect = expandElement.getBoundingClientRect();
110
- const headerOffsetTop =
111
- headerRect.top - parentRect.top + scrollParent.scrollTop;
112
-
113
- // 2. Si on a déjà scrollé vers ou au-delà du header, on ne remonte JAMAIS
114
- if (scrollParent.scrollTop >= headerOffsetTop - 5) {
115
- if (targetRect.bottom > parentRect.bottom) {
116
- target.scrollIntoView({ behavior: "smooth", block: "nearest" });
95
+ const performScroll = () => {
96
+ let scrollParent: HTMLElement | null = expandElement.parentElement;
97
+ while (scrollParent) {
98
+ const style = window.getComputedStyle(scrollParent);
99
+ const isScrollable =
100
+ /(auto|scroll)/.test(style.overflow + style.overflowY) &&
101
+ scrollParent.scrollHeight > scrollParent.clientHeight;
102
+
103
+ if (isScrollable) {
104
+ const parentRect = scrollParent.getBoundingClientRect();
105
+ const headerRect = expandElement.getBoundingClientRect();
106
+ const headerOffsetTop =
107
+ headerRect.top - parentRect.top + scrollParent.scrollTop;
108
+
109
+ // Si on a déjà scrollé vers ou au-delà du header, on ne remonte JAMAIS au header
110
+ if (scrollParent.scrollTop >= headerOffsetTop - 10) {
111
+ const targetRect = target.getBoundingClientRect();
112
+ if (targetRect.bottom > parentRect.bottom) {
113
+ target.scrollIntoView({ behavior: "smooth", block: "nearest" });
114
+ }
115
+ return;
117
116
  }
117
+
118
+ // Si on n'a pas encore scrollé jusqu'au header, on y va
119
+ scrollParent.scrollTo({
120
+ top: headerOffsetTop,
121
+ behavior: "smooth",
122
+ });
118
123
  return;
119
124
  }
120
-
121
- // 3. Sinon, on scrolle vers le header
122
- scrollParent.scrollTo({
123
- top: headerOffsetTop,
124
- behavior: "smooth",
125
- });
126
- return;
125
+ scrollParent = scrollParent.parentElement;
127
126
  }
128
- scrollParent = scrollParent.parentElement;
129
- }
127
+ };
128
+
129
+ performScroll();
130
+ // Répéter après l'ouverture du clavier virtuel (spécifique tablettes / mobiles Android)
131
+ setTimeout(performScroll, 300);
130
132
  }
131
133
  },
132
134
  [active],