@sio-group/ui-datatable 0.1.3 → 0.1.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @sio-group/ui-datatable
2
2
 
3
+ ## 0.1.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Bug: Fix action cel behavior
8
+
3
9
  ## 0.1.3
4
10
 
5
11
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -205,13 +205,15 @@ var ActionCell = ({
205
205
  if (dropdownRef.current && triggerRef.current) {
206
206
  const rect = triggerRef.current.getBoundingClientRect();
207
207
  dropdownRef.current.style.left = `${rect.left}px`;
208
- dropdownRef.current.style.top = `${rect.top}px`;
208
+ dropdownRef.current.style.top = `${rect.bottom}px`;
209
209
  }
210
210
  };
211
211
  (0, import_react2.useEffect)(() => {
212
212
  if (!isOpen) return;
213
+ positionDropdown();
213
214
  const handleOutside = (e) => {
214
215
  if (dropdownRef.current?.contains(e.target)) return;
216
+ if (triggerRef.current?.contains(e.target)) return;
215
217
  setIsOpen(false);
216
218
  };
217
219
  document.addEventListener("mousedown", handleOutside, false);
@@ -248,10 +250,7 @@ var ActionCell = ({
248
250
  "aria-label": "Acties",
249
251
  "aria-expanded": isOpen,
250
252
  "aria-haspopup": "menu",
251
- onClick: () => {
252
- setIsOpen(!isOpen);
253
- positionDropdown();
254
- },
253
+ onClick: () => setIsOpen(!isOpen),
255
254
  children: renderMenuIcon ? renderMenuIcon() : "\u22EE"
256
255
  }
257
256
  ),
package/dist/index.js CHANGED
@@ -179,13 +179,15 @@ var ActionCell = ({
179
179
  if (dropdownRef.current && triggerRef.current) {
180
180
  const rect = triggerRef.current.getBoundingClientRect();
181
181
  dropdownRef.current.style.left = `${rect.left}px`;
182
- dropdownRef.current.style.top = `${rect.top}px`;
182
+ dropdownRef.current.style.top = `${rect.bottom}px`;
183
183
  }
184
184
  };
185
185
  useEffect(() => {
186
186
  if (!isOpen) return;
187
+ positionDropdown();
187
188
  const handleOutside = (e) => {
188
189
  if (dropdownRef.current?.contains(e.target)) return;
190
+ if (triggerRef.current?.contains(e.target)) return;
189
191
  setIsOpen(false);
190
192
  };
191
193
  document.addEventListener("mousedown", handleOutside, false);
@@ -222,10 +224,7 @@ var ActionCell = ({
222
224
  "aria-label": "Acties",
223
225
  "aria-expanded": isOpen,
224
226
  "aria-haspopup": "menu",
225
- onClick: () => {
226
- setIsOpen(!isOpen);
227
- positionDropdown();
228
- },
227
+ onClick: () => setIsOpen(!isOpen),
229
228
  children: renderMenuIcon ? renderMenuIcon() : "\u22EE"
230
229
  }
231
230
  ),
@@ -163,7 +163,7 @@
163
163
  display: inline-block;
164
164
  }
165
165
  .datatable .action-dropdown__menu {
166
- position: absolute;
166
+ position: fixed;
167
167
  display: flex;
168
168
  flex-direction: column;
169
169
  background: var(--sio-datatable-bg);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sio-group/ui-datatable",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -173,7 +173,7 @@
173
173
  display: inline-block;
174
174
 
175
175
  &__menu {
176
- position: absolute;
176
+ position: fixed;
177
177
  display: flex;
178
178
  flex-direction: column;
179
179
  background: var(--sio-datatable-bg);
@@ -15,15 +15,18 @@ export const ActionCell = <T extends { id: string | number }> ({
15
15
  if (dropdownRef.current && triggerRef.current) {
16
16
  const rect: DOMRect = triggerRef.current.getBoundingClientRect();
17
17
  dropdownRef.current.style.left = `${rect.left}px`;
18
- dropdownRef.current.style.top = `${rect.top}px`;
18
+ dropdownRef.current.style.top = `${rect.bottom}px`;
19
19
  }
20
20
  }
21
21
 
22
22
  useEffect(() => {
23
23
  if (!isOpen) return;
24
24
 
25
+ positionDropdown();
26
+
25
27
  const handleOutside = (e: MouseEvent | Event) => {
26
28
  if (dropdownRef.current?.contains(e.target as Node)) return;
29
+ if (triggerRef.current?.contains(e.target as Node)) return;
27
30
  setIsOpen(false);
28
31
  }
29
32
 
@@ -65,10 +68,7 @@ export const ActionCell = <T extends { id: string | number }> ({
65
68
  aria-label="Acties"
66
69
  aria-expanded={isOpen}
67
70
  aria-haspopup="menu"
68
- onClick={() => {
69
- setIsOpen(!isOpen);
70
- positionDropdown();
71
- }}
71
+ onClick={() => setIsOpen(!isOpen)}
72
72
  >
73
73
  {renderMenuIcon ? renderMenuIcon() : '⋮'}
74
74
  </button>