Skip to content

fix: Waves tab icon alignment + draft caret follow-ups#3309

Merged
feruzm merged 3 commits into
developmentfrom
bugfix/waves-icon-and-caret-followups
Jun 27, 2026
Merged

fix: Waves tab icon alignment + draft caret follow-ups#3309
feruzm merged 3 commits into
developmentfrom
bugfix/waves-icon-and-caret-followups

Conversation

@feruzm

@feruzm feruzm commented Jun 27, 2026

Copy link
Copy Markdown
Member

Follow-ups to #3308 (already merged).

Waves tab icon alignment

The wavy-dash Waves icon sat ~15px higher than the other bottom-tab icons. Cause: react-native-svg's <Svg> ignores the shared paddingTop that the vector-font icons honor on their <Text>. Fix: apply that layout offset to a wrapping <View> (which honors padding) and let the parent tab cell center it horizontally, so the icon keeps the same footprint as the others across phones and tablets on iOS and Android.

Verifying visually on an iOS simulator; will tune by a pixel if the optical center needs it before this merges.

Draft caret follow-ups (review findings)

  • Missing caret now restores to the end of the body, not position 0. The body input auto-focuses for returning users, so a 0 default risked the keyboard opening at the top and prepending on the next keystroke. This also makes the caret feature purely additive — legacy drafts, drafts created on another device, and first opens after the feature shipped keep the long-standing end behavior; only drafts with a saved caret change.
  • Cancel the debounced caret persister on unmount. Prevents a pending 600ms write from firing after publish/first-save has cleared the entry (which would re-create an orphaned caretMap entry).

Testing

  • yarn lint clean, tsc clean (pre-existing tsconfig error only), editor reducer tests pass.
  • On-device alignment check across iPhone / iPad / Android still recommended before/after merge.

Summary by CodeRabbit

  • Bug Fixes

    • Improved caret restoration in the markdown editor: when no valid saved caret exists, the cursor now restores to the end of the draft instead of jumping to the start.
    • Ensured pending editor updates are committed on close, preventing delayed caret writes that could cause unexpected cursor behavior when reopening drafts.
  • Refactor

    • Updated icon rendering so layout, spacing, and padding behave consistently by applying styles to a wrapping container.

feruzm added 2 commits June 27, 2026 10:43
…ite on unmount

Review follow-ups to the draft-caret feature:
- When no caret is saved (legacy draft, cross-device draft, first open after
  this shipped), restore to the end of the body instead of position 0. Keeps
  the feature purely additive and avoids dropping the auto-focused cursor at
  the top (where immediate typing would prepend to the post).
- Cancel the debounced caret persister on unmount so a late write can't
  re-create a caretMap entry that publish/first-save just cleared.
react-native-svg's <Svg> ignored the shared paddingTop the vector-font tab
icons honor on their <Text>, so the Waves icon sat ~15px too high. Apply the
layout style (the tab bar's top offset) to a wrapping <View> instead, which
honors padding; the parent tab cell centers it horizontally. Keeps the same
footprint as the other icons across phones and tablets on iOS and Android.
@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 13ce8714-ba3e-4a96-a57f-59b0e945e965

📥 Commits

Reviewing files that changed from the base of the PR and between 68322b1 and d37b034.

📒 Files selected for processing (1)
  • src/components/markdownEditor/view/markdownEditorView.tsx

📝 Walkthrough

Walkthrough

The wavy dash icon now applies styling through a wrapping View, and the markdown editor now restores an unsaved caret to the end of the draft and flushes pending debounced writes on unmount.

Changes

Wavy dash icon layout

Layer / File(s) Summary
Wrap SVG in View
src/assets/svgs/wavy-dash-icon.tsx
WavyDashIcon now wraps its Svg in a View, applies the incoming style to that wrapper, and keeps the SVG path and dimensions unchanged.

Markdown editor caret handling

Layer / File(s) Summary
Restore and flush caret persistence
src/components/markdownEditor/view/markdownEditorView.tsx
When no saved caret number exists for the current draft key, the caret now restores to draftBody.length; unmount cleanup flushes the debounced caret persistence and text-change writes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • ecency/ecency-mobile#3308: Modifies the same markdown editor caret restore/persistence flow, including handling missing caret values and debounced caret writes.

Poem

A bunny hopped by with a wavy dash grin,
I wrapped the SVG so the style could tuck in.
For drafts, I saved where the caret should lie,
Then flushed sleepy edits before saying goodbye.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the two main changes: Waves tab icon alignment and draft caret follow-ups.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bugfix/waves-icon-and-caret-followups

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/markdownEditor/view/markdownEditorView.tsx`:
- Around line 249-252: The unmount cleanup in markdownEditorView still only
cancels _persistCaret, so _debouncedOnTextChange can run after unmount and
trigger stale body writes and setIsEditing(false). Update the existing useEffect
cleanup near _persistCaret to also cancel _debouncedOnTextChange, using the same
unmount teardown path in markdownEditorView. Keep the fix localized to the
editor lifecycle cleanup so both debounced callbacks are stopped before any
publish/first-save state is cleared.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c43102b1-96c0-4a77-a9bf-4b182beb3b55

📥 Commits

Reviewing files that changed from the base of the PR and between 7418d18 and 68322b1.

📒 Files selected for processing (2)
  • src/assets/svgs/wavy-dash-icon.tsx
  • src/components/markdownEditor/view/markdownEditorView.tsx

Comment thread src/components/markdownEditor/view/markdownEditorView.tsx Outdated
@greptile-apps

greptile-apps Bot commented Jun 27, 2026

Copy link
Copy Markdown

Greptile Summary

This PR updates Waves tab rendering and draft caret persistence. The main changes are:

  • Applies Waves icon tab padding through a wrapping View.
  • Restores drafts without a saved caret to the end of the body.
  • Flushes pending debounced caret and body updates during editor teardown.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
src/assets/svgs/wavy-dash-icon.tsx Applies the tab icon layout offset to a wrapping native view around the Waves SVG.
src/components/markdownEditor/view/markdownEditorView.tsx Updates draft caret fallback behavior and flushes pending editor persistence work on unmount.

Reviews (2): Last reviewed commit: "fix(editor): flush (not cancel) pending ..." | Re-trigger Greptile

Comment thread src/components/markdownEditor/view/markdownEditorView.tsx Outdated
…ount

Review follow-up: cancelling _persistCaret on unmount dropped the caret when
the user moved the cursor and left within the 600ms window (stale caret on
reopen), and the body debounce (_debouncedOnTextChange) could still fire after
unmount. Flush both on unmount so the latest caret and body are committed
synchronously before teardown, addressing both the dropped-caret and
late-body-write windows.
@feruzm

feruzm commented Jun 27, 2026

Copy link
Copy Markdown
Member Author

Both review comments point at the same unmount cleanup, and they pull in opposite directions:

  • CodeRabbit (Major): also handle _debouncedOnTextChange on unmount (the body debounce has the same late-fire window).
  • Greptile (P1): _persistCaret.cancel() drops a pending caret if the cursor moved within the 600ms window → stale caret on reopen.

Resolved both with .flush() instead of .cancel() (d37b034):

useEffect(
  () => () => {
    _persistCaret.flush();
    _debouncedOnTextChange.flush();
  },
  [_persistCaret, _debouncedOnTextChange],
);

Flushing commits the pending caret and body synchronously during the unmount cleanup (which runs before the parent's unmount save), so:

  • Greptile: the last cursor move is persisted, not dropped — no stale caret on reopen.
  • CodeRabbit: the body debounce is handled too, and runs synchronously rather than firing after unmount; it also stops losing the last ~500ms of typing.

The only residual is a harmless, rare orphan caretMap entry if the cursor moved <600ms before publish (publish clears the entry, then the flush re-adds it for an already-published draft) — bounded and never read, which I judged a better trade than Greptile's user-facing stale-caret.

@feruzm feruzm merged commit de90ec9 into development Jun 27, 2026
10 of 12 checks passed
@feruzm feruzm deleted the bugfix/waves-icon-and-caret-followups branch June 27, 2026 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant