# Mobile Article Editor Implementation Plan > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. **Goal:** Make the existing article editor usable on a 320–430 px phone, with an explicit safe return to drafts and no horizontal overflow. **Architecture:** Keep the current `selectedArticle` overlay and Editor.js instance. Add a small, local editor-navigation state machine in `App.tsx` for close confirmation and a mobile-only command hierarchy: persistent back/status top bar, main save/publish bottom bar, and a native disclosure for secondary actions. Use scoped CSS in `index.css` so desktop controls preserve their current layout. **Tech Stack:** React 19, TypeScript, Tailwind CSS, shadcn-style `Button`, Editor.js, Vite. --- ## File structure - Modify: `admin/src/App.tsx` — editor return guard, responsive action groups, semantic feature-image trigger and keyboard handling. - Modify: `admin/src/index.css` — 640 px task-view layout, safe-area bottom actions, touch sizes and no-overflow rules. - Modify: `admin/src/components/ui/button.tsx` — add a reusable 44 px `touch-icon` button size without changing existing compact desktop sizes. ### Task 1: Safe return from the editor **Files:** - Modify: `admin/src/App.tsx:1211-1235,1624-1640,2108-2115,2695-2773` - [ ] **Step 1: Reproduce the loss-of-context path** Run the Vite app, open a draft, make a title change, then use the current close icon. Expected: the modal closes immediately, with no explicit return label or save/discard decision. - [ ] **Step 2: Add local close-confirmation state and a single `requestArticleClose` function** Add `articleCloseConfirmOpen` beside the existing editor state. Implement `requestArticleClose` so it calls `setSelectedArticle(null)` immediately only when `editorDirty` is false; otherwise it opens a confirmation panel. Implement explicit handlers: `stayInArticle`, `discardArticleChanges`, and `saveAndCloseArticle` (await `saveArticle(false)` first; only close after it resolves). ```ts function requestArticleClose() { if (!editorDirty) { setSelectedArticle(null) return } setArticleCloseConfirmOpen(true) } async function saveAndCloseArticle() { const saved = await saveArticle(false) if (saved) setSelectedArticle(null) } ``` - [ ] **Step 3: Route all editor exits through the guard** Replace the header close callback with `requestArticleClose`. In `saveAndPublishArticle`, retain closing only after the successful publish request. Add a `keydown` effect active while `selectedArticle` is set: Escape closes the secondary-actions disclosure if open, otherwise calls `requestArticleClose`. - [ ] **Step 4: Render an accessible confirmation panel** Render a labelled modal/panel only while `articleCloseConfirmOpen` is true. It must contain: title «Сохранить изменения?», text explaining that unsaved edits stay only in this browser, and buttons «Остаться», «Не сохранять», «Сохранить и выйти». Disable the save button while `editorBusy` is true. Return focus to the «К черновикам» trigger when the panel closes. - [ ] **Step 5: Manually verify return behavior** Check each branch: clean back closes; dirty → stay remains; dirty → discard closes; dirty → save waits for the PATCH, then closes; publish still refreshes the list and closes only on success. - [ ] **Step 6: Commit** ```bash git add admin/src/App.tsx git commit -m "feat: guard article editor return" ``` ### Task 2: Establish the mobile command hierarchy **Files:** - Modify: `admin/src/App.tsx:2695-2776` - Modify: `admin/src/components/ui/button.tsx:5-30` - [ ] **Step 1: Establish the expected mobile arrangement** At 390 px, inspect the editor header. Expected failure before the change: the primary navigation competes with a copy button, a long generate button, save, date input, publish, delete, and close. - [ ] **Step 2: Add a 44 px icon-button size** Extend the `size` variants in `button.tsx` with `touch-icon: "size-11"`. Keep `icon` at 36 px so lists and desktop controls do not shift. ```ts touchIcon: "size-11", ``` Use the TypeScript-compatible variant key actually chosen in the component (`touchIcon`), not a hyphenated prop. - [ ] **Step 3: Split editor actions into persistent and secondary groups** In the selected-article header, add a labelled back button containing `ChevronLeft` and visible text «К черновикам» that calls `requestArticleClose`. Keep the current article status and save state in the top section. Put copy, image generation, schedule input and deletion into a `
` / `` labelled «Ещё» on mobile; desktop keeps the existing direct controls through responsive utility classes. Leave the current save and publish callbacks unchanged. - [ ] **Step 4: Add a mobile action footer** Render a `.article-mobile-actions` group after the scrollable editor body. It has a full-width «Сохранить» button (disabled if clean or busy) and a full-width «Опубликовать»/«Запланировать» button based on the existing `isScheduledForFuture` and `publishAt` state. Both reuse `saveArticle` and `saveAndPublishArticle`; no duplicate request code. - [ ] **Step 5: Preserve keyboard semantics** Use real `