forstok-ui-lib 8.5.6 → 8.5.7

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,6 +1,6 @@
1
1
  {
2
2
  "name": "forstok-ui-lib",
3
- "version": "8.5.6",
3
+ "version": "8.5.7",
4
4
  "description": "Forstok UI Components Library",
5
5
  "path": "dist",
6
6
  "main": "dist/index.js",
@@ -21,6 +21,7 @@ const DropDownComponent = ({ children, title, subTitle, $externalWidth, $externa
21
21
  const getViewportWidth = () => window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
22
22
 
23
23
  const getDropdownWrapperElement = (parentEl: ParentNode | null) => parentEl?.querySelector('._refDropdownWrapper') as HTMLElement | null;
24
+ const withNextFrame = (callback: () => void) => window.requestAnimationFrame(() => callback());
24
25
 
25
26
  const getDropdownPlacement = (containerEl: HTMLElement, wrapperEl: HTMLElement) => {
26
27
  if ($placement === 'top') {
@@ -67,6 +68,14 @@ const DropDownComponent = ({ children, title, subTitle, $externalWidth, $externa
67
68
  wrapperEl.style.left = '';
68
69
  wrapperEl.style.right = '';
69
70
  wrapperEl.style.transform = '';
71
+ wrapperEl.style.visibility = '';
72
+ }
73
+ };
74
+
75
+ const setDropdownVisibility = (parentEl: ParentNode | null, visibility: 'hidden' | 'visible') => {
76
+ const wrapperEl = getDropdownWrapperElement(parentEl);
77
+ if (wrapperEl) {
78
+ wrapperEl.style.visibility = visibility;
70
79
  }
71
80
  };
72
81
 
@@ -170,6 +179,9 @@ const DropDownComponent = ({ children, title, subTitle, $externalWidth, $externa
170
179
  evResetDropdown();
171
180
  overlayEl.style.display = 'block';
172
181
  bodyEl.classList.add('is-immuned');
182
+ if (!portalId) {
183
+ setDropdownVisibility(containerEl, 'hidden');
184
+ }
173
185
  containerEl.classList.add('is-shown');
174
186
  setTimeout(() => {
175
187
  if (portalId) {
@@ -183,7 +195,10 @@ const DropDownComponent = ({ children, title, subTitle, $externalWidth, $externa
183
195
  }, 10);
184
196
  }
185
197
  } else {
186
- setInlineDropdownPlacement(containerEl);
198
+ withNextFrame(() => {
199
+ setInlineDropdownPlacement(containerEl);
200
+ setDropdownVisibility(containerEl, 'visible');
201
+ });
187
202
  }
188
203
  }, 10);
189
204
  onClick && onClick(e);