Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/components/wordpress/dataviews.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
*/
function getQueryParamsFromView(view: View, tabViewKey: string): Record<string, string | number | null | undefined> {
const v = view as View & {
[key: string]: any;

Check warning on line 85 in src/components/wordpress/dataviews.tsx

View workflow job for this annotation

GitHub Actions / build-and-test

Unexpected any. Specify a different type
};

const perPage = v.perPage ?? v.per_page;
Expand All @@ -91,7 +91,7 @@
typeof v.filters === 'object' && Object.keys(v.filters).length > 0 ? JSON.stringify(v.filters) : null;

// Start with the core pieces of state we always want in the URL.
const params: Record<string, any> = {

Check warning on line 94 in src/components/wordpress/dataviews.tsx

View workflow job for this annotation

GitHub Actions / build-and-test

Unexpected any. Specify a different type
// Use `current_page` instead of `page` so we don't conflict with
// WordPress admin's own `page` query param (e.g. ?page=plugin-ui-test).
current_page: v.page ?? null,
Expand Down Expand Up @@ -519,12 +519,31 @@

// --- Destructive action confirmation via AlertDialog ---
const [pendingDestructiveAction, setPendingDestructiveAction] = useState<{
action: DataViewAction<Item> & { callback: (...args: any[]) => void };

Check warning on line 522 in src/components/wordpress/dataviews.tsx

View workflow job for this annotation

GitHub Actions / build-and-test

Unexpected any. Specify a different type
items: Item[];
context: any;

Check warning on line 524 in src/components/wordpress/dataviews.tsx

View workflow job for this annotation

GitHub Actions / build-and-test

Unexpected any. Specify a different type
} | null>(null);
const [isConfirming, setIsConfirming] = useState(false);

// Ariakit (WP Menu) and base-ui (AlertDialog) both manipulate body scroll
// styles independently. When one saves the other's overflow:hidden as the
// "original" state, closing the dialog restores that instead of the clean
// state. Force-clear after all their scheduled cleanups have run.
const prevPendingRef = useRef(pendingDestructiveAction);
useEffect(() => {
const wasOpen = prevPendingRef.current !== null;
const isClosed = pendingDestructiveAction === null;
prevPendingRef.current = pendingDestructiveAction;

if (wasOpen && isClosed) {
const timer = setTimeout(() => {
document.body.style.overflow = '';
document.documentElement.style.overflow = '';
}, 0);
return () => clearTimeout(timer);
}
}, [pendingDestructiveAction]);
Comment thread
coderabbitai[bot] marked this conversation as resolved.

const handleDestructiveConfirm = useCallback(async () => {
if (pendingDestructiveAction) {
setIsConfirming(true);
Expand Down Expand Up @@ -906,7 +925,7 @@
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel onClick={handleDestructiveCancel} disabled={isConfirming}>
<AlertDialogCancel disabled={isConfirming}>
{pendingDestructiveAction.action.cancelButtonLabel || __('Cancel', 'default')}
</AlertDialogCancel>
<AlertDialogAction
Expand Down
Loading