Skip to content

Commit fd1da7b

Browse files
authored
Merge pull request #316 from catsimple/fix_stuck_on_overlay
Fix stuck on overlay
2 parents f5dcf82 + a7b689d commit fd1da7b

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

  • browser_utils/initialization

browser_utils/initialization/core.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -586,27 +586,21 @@ async def _is_temporary_chat_active(page: AsyncPage) -> bool:
586586
except Exception:
587587
continue
588588

589+
# New menu UI: active state is represented by a checkmark inside the menu item.
590+
try:
591+
checkmark_locator = page.locator("[data-test-incognito-checkmark]")
592+
if await checkmark_locator.count() > 0:
593+
return True
594+
except Exception:
595+
pass
596+
589597
# Menu button variants (legacy and gray-release UI).
590598
toggle_locator = page.locator(
591599
"button[data-test-incognito-toggle], "
592600
'button[aria-label="Temporary chat toggle"], '
593601
'button[aria-label="Toggle temporary chat"]'
594602
)
595603
if await toggle_locator.count() > 0:
596-
# New UI: active state is represented by a checkmark inside the menu item.
597-
try:
598-
checkmark_locator = page.locator(
599-
"button[data-test-incognito-toggle] [data-test-incognito-checkmark], "
600-
'button[aria-label="Temporary chat toggle"] [data-test-incognito-checkmark], '
601-
'button[aria-label="Toggle temporary chat"] [data-test-incognito-checkmark]'
602-
)
603-
if (
604-
await checkmark_locator.count() > 0
605-
):
606-
return True
607-
except Exception:
608-
pass
609-
610604
# Legacy/alternative signals.
611605
for attr_name in ("aria-pressed", "aria-checked"):
612606
try:
@@ -656,6 +650,11 @@ async def _close_menu_if_needed() -> None:
656650
pass
657651

658652
try:
653+
if await _is_temporary_chat_active(page):
654+
logger.debug("[UI] Temporary chat mode already active")
655+
await _close_menu_if_needed()
656+
return True
657+
659658
# Fast path
660659
logger.debug("[UI] Searching for temporary chat button (Fast path)")
661660
try:

0 commit comments

Comments
 (0)