forstok-ui-lib 8.5.6 → 8.5.8

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.8",
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') {
@@ -50,6 +51,7 @@ const DropDownComponent = ({ children, title, subTitle, $externalWidth, $externa
50
51
 
51
52
  const applyDropdownPlacement = (wrapperEl: HTMLElement, placement: 'top' | 'bottom') => {
52
53
  if (placement === 'top') {
54
+ wrapperEl.style.animation = 'none'; // stop CSS animation from overriding top:auto
53
55
  wrapperEl.style.top = 'auto';
54
56
  wrapperEl.style.bottom = `${getOffsetValue($bottom, DEFAULT_BOTTOM_OFFSET)}px`;
55
57
  return;
@@ -67,6 +69,15 @@ const DropDownComponent = ({ children, title, subTitle, $externalWidth, $externa
67
69
  wrapperEl.style.left = '';
68
70
  wrapperEl.style.right = '';
69
71
  wrapperEl.style.transform = '';
72
+ wrapperEl.style.visibility = '';
73
+ wrapperEl.style.animation = '';
74
+ }
75
+ };
76
+
77
+ const setDropdownVisibility = (parentEl: ParentNode | null, visibility: 'hidden' | 'visible') => {
78
+ const wrapperEl = getDropdownWrapperElement(parentEl);
79
+ if (wrapperEl) {
80
+ wrapperEl.style.visibility = visibility;
70
81
  }
71
82
  };
72
83
 
@@ -170,6 +181,9 @@ const DropDownComponent = ({ children, title, subTitle, $externalWidth, $externa
170
181
  evResetDropdown();
171
182
  overlayEl.style.display = 'block';
172
183
  bodyEl.classList.add('is-immuned');
184
+ if (!portalId) {
185
+ setDropdownVisibility(containerEl, 'hidden');
186
+ }
173
187
  containerEl.classList.add('is-shown');
174
188
  setTimeout(() => {
175
189
  if (portalId) {
@@ -183,7 +197,10 @@ const DropDownComponent = ({ children, title, subTitle, $externalWidth, $externa
183
197
  }, 10);
184
198
  }
185
199
  } else {
186
- setInlineDropdownPlacement(containerEl);
200
+ withNextFrame(() => {
201
+ setInlineDropdownPlacement(containerEl);
202
+ setDropdownVisibility(containerEl, 'visible');
203
+ });
187
204
  }
188
205
  }, 10);
189
206
  onClick && onClick(e);