From 0cd868ce4ad3dd62fa54044aa8a9980d95056a52 Mon Sep 17 00:00:00 2001
From: Alexander Platov <sas_lord@mail.ru>
Date: Wed, 25 Jan 2023 19:46:32 +0300
Subject: [PATCH] Fix Jumping popup (#2545)

Signed-off-by: Alexander Platov <sas_lord@mail.ru>
---
 packages/theme/styles/popups.scss                         | 5 +++--
 packages/ui/src/components/PopupInstance.svelte           | 1 -
 packages/ui/src/components/SelectPopup.svelte             | 8 ++------
 .../src/components/DocRemindersPopup.svelte               | 3 ++-
 .../src/components/RemindersPopup.svelte                  | 3 ++-
 .../src/components/NotificationsPopup.svelte              | 3 ++-
 .../request-resources/src/components/RequestsPopup.svelte | 3 ++-
 7 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/packages/theme/styles/popups.scss b/packages/theme/styles/popups.scss
index 56c78133e4..da8bd916ca 100644
--- a/packages/theme/styles/popups.scss
+++ b/packages/theme/styles/popups.scss
@@ -420,12 +420,13 @@
   display: flex;
   flex-direction: column;
   padding: .5rem;
-  min-width: 22rem;
   min-height: 22rem;
   background: var(--popup-bg-color);
   border-radius: .5rem;
   box-shadow: var(--popup-shadow);
-
+  
+  &:not(.min-w-168) { min-width: 22rem; }
+  
   .header {
     display: flex;
     align-items: center;
diff --git a/packages/ui/src/components/PopupInstance.svelte b/packages/ui/src/components/PopupInstance.svelte
index a7e3b5af4d..382fba7b84 100644
--- a/packages/ui/src/components/PopupInstance.svelte
+++ b/packages/ui/src/components/PopupInstance.svelte
@@ -54,7 +54,6 @@
 
   function _update (result: any): void {
     if (onUpdate !== undefined) onUpdate(result)
-    fitPopup()
   }
 
   function _close (result: any): void {
diff --git a/packages/ui/src/components/SelectPopup.svelte b/packages/ui/src/components/SelectPopup.svelte
index 34a8af6e56..dd876c214c 100644
--- a/packages/ui/src/components/SelectPopup.svelte
+++ b/packages/ui/src/components/SelectPopup.svelte
@@ -140,9 +140,7 @@
       />
     </div>
   {/if}
-  {#if cHeight === 1}
-    <div class="background-theme-content-accent" style:height={'2px'} />
-  {/if}
+  <div class:background-accent-bg-color={cHeight === 1} style:height={'2px'} />
   <div class="scroll" on:scroll={() => updateLocation(scrollDiv, selectedDiv, filteredObjects)} bind:this={scrollDiv}>
     <div class="box">
       <ListView
@@ -204,7 +202,5 @@
       </ListView>
     </div>
   </div>
-  {#if cHeight === -1}
-    <div class="background-theme-content-accent" style:height={'2px'} />
-  {/if}
+  <div class:background-accent-bg-color={cHeight === -1} style:height={'2px'} />
 </div>
diff --git a/plugins/calendar-resources/src/components/DocRemindersPopup.svelte b/plugins/calendar-resources/src/components/DocRemindersPopup.svelte
index 3051a28432..475a148223 100644
--- a/plugins/calendar-resources/src/components/DocRemindersPopup.svelte
+++ b/plugins/calendar-resources/src/components/DocRemindersPopup.svelte
@@ -29,9 +29,10 @@
   }
 
   const currentUser = getCurrentAccount() as EmployeeAccount
+  $: isMobile = $deviceInfo.isMobile
 </script>
 
-<div class="notifyPopup" class:min-w-168={!$deviceInfo.isMobile}>
+<div class="notifyPopup" class:min-w-168={!isMobile}>
   <div class="header flex-between">
     <span class="fs-title overflow-label"><Label label={calendar.string.Reminders} /></span>
     <Button icon={IconAdd} size={'medium'} kind={'transparent'} on:click={(e) => click(e)} />
diff --git a/plugins/calendar-resources/src/components/RemindersPopup.svelte b/plugins/calendar-resources/src/components/RemindersPopup.svelte
index 1f5047a049..b976b80752 100644
--- a/plugins/calendar-resources/src/components/RemindersPopup.svelte
+++ b/plugins/calendar-resources/src/components/RemindersPopup.svelte
@@ -27,9 +27,10 @@
   $: query.query(calendar.mixin.Reminder, { state: 'active', participants: currentUser.employee }, (res) => {
     remindersCount = res.length
   })
+  $: isMobile = $deviceInfo.isMobile
 </script>
 
-<div class="notifyPopup" class:justify-center={!remindersCount} class:min-w-168={!$deviceInfo.isMobile}>
+<div class="notifyPopup" class:justify-center={!remindersCount} class:min-w-168={!isMobile}>
   <div class="header">
     <span class="fs-title overflow-label"><Label label={calendar.string.Reminders} /></span>
   </div>
diff --git a/plugins/notification-resources/src/components/NotificationsPopup.svelte b/plugins/notification-resources/src/components/NotificationsPopup.svelte
index b8cc45b163..223cb4c4e9 100644
--- a/plugins/notification-resources/src/components/NotificationsPopup.svelte
+++ b/plugins/notification-resources/src/components/NotificationsPopup.svelte
@@ -75,9 +75,10 @@
       }
     }
   }
+  $: isMobile = $deviceInfo.isMobile
 </script>
 
-<div class="notifyPopup" class:justify-center={notifications.length === 0} class:min-w-168={!$deviceInfo.isMobile}>
+<div class="notifyPopup" class:justify-center={notifications.length === 0} class:min-w-168={!isMobile}>
   <div class="header flex-between">
     <span class="fs-title overflow-label"><Label label={notification.string.Notifications} /></span>
     {#if notifications.length > 0}
diff --git a/plugins/request-resources/src/components/RequestsPopup.svelte b/plugins/request-resources/src/components/RequestsPopup.svelte
index 69cab3bbc7..dfcf87703e 100644
--- a/plugins/request-resources/src/components/RequestsPopup.svelte
+++ b/plugins/request-resources/src/components/RequestsPopup.svelte
@@ -35,9 +35,10 @@
         (p) => p.requested.filter((a) => a === me).length > p.approved.filter((a) => a === me).length
       ))
   )
+  $: isMobile = $deviceInfo.isMobile
 </script>
 
-<div class="notifyPopup" class:justify-center={requests.length === 0} class:min-w-168={!$deviceInfo.isMobile}>
+<div class="notifyPopup" class:justify-center={requests.length === 0} class:min-w-168={!isMobile}>
   <div class="header flex-between">
     <span class="fs-title overflow-label"><Label label={request.string.Requests} /></span>
   </div>