wordpress-mobile / wordpress-mobile/GutenbergKit
Lockdown Mode sheet is lost when the editor is already presenting
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29
- Forks
- 6
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 41
Description
LockdownModeMonitor.presentSheetIfNeeded consumes its one-shot flags before it attempts the presentation, so a presentation that fails silently costs the user the warning for the rest of that editor session.
Detail
ios/Sources/GutenbergKit/Sources/Services/LockdownModeMonitor.swift:148-150 sets hasShownSheet = true and shouldShowSheet = false, and only then calls presentingViewController.present(hostingController, animated: true) at :176. Nothing re-checks whether the presentation actually happened — present(_:animated:) is a no-op when the presenter is already presenting something.
Recovery is closed off too. handleWillEnterForeground early-returns at :119 on guard newValue != self.isLockdownModeEnabled, so while Lockdown Mode stays enabled the value never changes and resetForForegroundCheck() (:95) is unreachable. detectLockdownMode only re-arms shouldShowSheet on a disabled → enabled transition with !hasShownSheet (:79-80).
How it bites
The editor finishes loading while it is already presenting something — a sheet the user opened, or a host-presented modal. didLoadEditor() (EditorViewController.swift:889) calls presentSheetIfNeeded at :908, the flags are consumed, the present silently does nothing, and the Lockdown Mode user never sees the explanation for why the editor may misbehave.
Scoped to that editor instance — lockdownModeMonitor is constructed per editor (EditorViewController.swift:229), so the next editor gets a fresh monitor. Not permanent, but the warning is lost for the session it mattered in.
Suggested fix
Set the flags after a confirmed presentation, or guard on presentingViewController.presentedViewController == nil before consuming them.
Found while reviewing #651. Pre-existing; not introduced there.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in ios/Sources/GutenbergKit/Sources/Services/LockdownModeMonitor.swift around presentSheetIfNeeded, then trace didLoadEditor() in EditorViewController.swift. Verify the flags are not consumed when the editor is already presenting another controller, and that the Lockdown Mode explanation appears once a presentation is possible during the same editor session.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100