cerxos-ui 0.0.9 → 0.0.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.
@@ -206,26 +206,23 @@ class CxsActionMenuComponent {
206
206
  }
207
207
  const rect = trigger.getBoundingClientRect();
208
208
  const offset = 8;
209
- this.menuPosition = {
210
- top: rect.bottom + offset,
211
- left: rect.left
212
- };
213
209
  setTimeout(() => {
214
210
  const menuEl = this.menu?.nativeElement;
215
211
  const menuRect = menuEl?.getBoundingClientRect();
216
- if (!menuRect) {
217
- return;
218
- }
212
+ const measuredWidth = menuRect?.width ?? 0;
213
+ const measuredHeight = menuRect?.height ?? 0;
214
+ const menuWidth = measuredWidth > 1 ? measuredWidth : 160;
215
+ const menuHeight = measuredHeight > 1 ? measuredHeight : 0;
219
216
  let top = rect.bottom + offset;
220
- let left = this.align === 'end' ? rect.right - menuRect.width : rect.left;
221
- if (top + menuRect.height > window.innerHeight) {
222
- top = rect.top - menuRect.height - offset;
217
+ let left = this.align === 'end' ? rect.right - menuWidth : rect.left;
218
+ if (top + menuHeight > window.innerHeight) {
219
+ top = rect.top - menuHeight - offset;
223
220
  }
224
221
  if (top < offset) {
225
222
  top = offset;
226
223
  }
227
- if (left + menuRect.width > window.innerWidth - offset) {
228
- left = Math.max(offset, window.innerWidth - menuRect.width - offset);
224
+ if (left + menuWidth > window.innerWidth - offset) {
225
+ left = Math.max(offset, window.innerWidth - menuWidth - offset);
229
226
  }
230
227
  if (left < offset) {
231
228
  left = offset;