@growth-operations/ui-shared 1.6.9 → 1.6.10

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": "@growth-operations/ui-shared",
3
- "version": "1.6.9",
3
+ "version": "1.6.10",
4
4
  "description": "Shared HubSpot UI-extension modules (Home, Billing) for Growth Operations apps.",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -166,10 +166,25 @@ export function AlertsTab({
166
166
 
167
167
  // Optimistically remove a dismissed alert from local state instead of
168
168
  // re-fetching the whole list. Keeps the dismiss interaction to a single API
169
- // call (the dismiss itself).
169
+ // call (the dismiss itself) in the common case. But if removing the row empties
170
+ // the current page while other pages still have alerts, fall back to a fetch so
171
+ // the user isn't stranded on a falsely-empty "No alerts" view: backfill this
172
+ // page, or step back a page if we just cleared the last one.
170
173
  const removeAlertLocally = (id) => {
171
- setAlerts((prev) => prev.filter((a) => a.id !== id));
172
- setTotal((t) => Math.max(0, t - 1));
174
+ const remainingHere = alerts.filter((a) => a.id !== id);
175
+ const newTotal = Math.max(0, total - 1);
176
+
177
+ if (remainingHere.length === 0 && newTotal > 0) {
178
+ // Page emptied but more remain — reload. If this was the last page and it's
179
+ // now gone, step back one; otherwise reload the same page to pull the next
180
+ // page's rows up into it.
181
+ const lastPage = Math.max(1, Math.ceil(newTotal / PAGE_SIZE));
182
+ load(Math.min(page, lastPage), level);
183
+ return;
184
+ }
185
+
186
+ setAlerts(remainingHere);
187
+ setTotal(newTotal);
173
188
  };
174
189
 
175
190
  useEffect(() => {