Skip to content

Remove inline-flex from comment anchors and reset chat row text alignment#92776

Merged
Beamanator merged 1 commit into
mainfrom
claude-anchorInlineWrapAndAlignFix
Jun 5, 2026
Merged

Remove inline-flex from comment anchors and reset chat row text alignment#92776
Beamanator merged 1 commit into
mainfrom
claude-anchorInlineWrapAndAlignFix

Conversation

@MelvinBot
Copy link
Copy Markdown
Contributor

@MelvinBot MelvinBot commented Jun 5, 2026

Explanation of Change

This re-applies the change from the reverted #92387 and additionally fixes the deploy blocker it caused (#92668).

1. Re-apply #92387 — links wrap inline (#90362)

Comment anchors (and their text children) in AnchorRenderer.tsx were styled with styles.dInlineFlex (display: inline-flex). On web this turns each link into an atomic inline-flex box, so a multi-word link can't break across line boxes — when it doesn't fit it gets pushed onto its own line instead of wrapping inline at word boundaries. Removing styles.dInlineFlex lets links participate in normal inline text flow and wrap naturally.

2. Fix the regression — sole long link/email wrapped line was centered (#92668)

Removing the anchor's inline-flex exposed a pre-existing inherited text-align: center. Every chat message row renders as a PressableWithSecondaryInteraction with accessibilityRole="button", which react-native-web renders as a native <button>. The browser UA stylesheet sets text-align: center on <button>, and since text-align is inherited and RNW's base view reset doesn't override it, the center cascades down into the <comment> block. Normal messages are unaffected because every RNW <Text> resets alignment — but a message whose entire content is a single auto-linked email/URL has no resetting <Text> wrapper, so its wrapped (second) line obeyed the inherited center.

The fix resets textAlign to left on that PressableWithSecondaryInteraction so the native <button>'s inherited center never cascades to its descendants. (React Native's textAlign type only supports left/right/etc., not the CSS start keyword; for all currently shipped LTR locales left is equivalent to start.)

Fixed Issues

$ #90362
$ #92668
PROPOSAL: #90362 (comment)

MelvinBot verification

Verified in the web build at a narrow viewport (links forced to wrap):

  • ✅ Multi-word inline hyperlink flows inline with the surrounding sentence and wraps at word boundaries (no longer pushed onto its own line).
  • ✅ A sole long email/URL's wrapped second line is left-aligned (no longer centered). DOM inspection confirmed textAlign: left throughout the ancestor chain from the <a> up to the chat row.

Both fixes at narrow width: inline hyperlink wraps inline (issue 90362) and long email wrapped second line is left-aligned (issue 92668)
Multi-word inline hyperlink flows inline with the surrounding sentence
Long email address: wrapped second line is left-aligned, not centered

AI Tests (run by MelvinBot)
  • npx prettier --write on both changed files — clean
  • npx eslint on both changed files — passed (0 errors; 1 pre-existing seatbelt-allowed warning unrelated to this change)
  • npm run typecheck-tsgo — passed
  • npm run react-compiler-compliance-check check <files> — both COMPILED
  • npm test -- tests/ui/PureReportActionItemTest.tsx — 190/190 passed

Tests

// TODO: The human co-author must fill out the tests you ran before marking this PR as "ready for review"
// Please describe what tests you performed that validates your changed worked.

  1. Sign in and open any chat (1:1 DM, workspace room, or transaction thread).
  2. Send a comment containing a multi-word inline hyperlink in the middle of a sentence, e.g.:

    FYI, I probably could have imported this receipt automatically. Would you be open to connecting your personal or company card? I support over 10,000 banks around the world, so I can probably connect to yours!

  3. Verify the linked text flows inline with the surrounding sentence and wraps at word boundaries — it should not be forced onto its own line.
  4. Send a message whose entire content is a single long email or URL, e.g. sjodinjsojsiojiodnjiosjionsjidnjsijiosndjoinjiosjidoj@gmail.com.
  5. Narrow the window / chat pane so the link wraps, and verify the wrapped second line is left-aligned (not centered).
  6. Click the link and verify it still opens correctly.
  7. Regression: verify other message content (plain text, bold, italic, code blocks, quotes, mentions, other links) still renders and wraps as expected.
  • Verify that no errors appear in the JS console

Offline tests

Same as Tests — messages render client-side, so the inline link wrapping and alignment behavior is identical while offline. Compose and send the comments above while offline and verify the optimistic messages render correctly.

QA Steps

// TODO: The human co-author must fill out the QA tests you ran before marking this PR as "ready for review".
// Please describe what QA needs to do to validate your changes and what areas do they need to test for regressions.

  1. Open any chat (1:1 DM, workspace room, or transaction thread).
  2. Send a comment with a multi-word inline hyperlink in the middle of a sentence (see Tests).
  3. Verify the linked text flows inline and wraps at word boundaries instead of being pushed onto its own line.
  4. Send a message whose entire content is a single long email/URL, narrow the window so it wraps, and verify the wrapped second line is left-aligned (not centered).
  5. Click the link and verify it opens correctly.
  6. Regression: verify other message content (plain text, bold, italic, code blocks, quotes, mentions, other links) still renders and wraps as expected.
  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

…ment

Re-applies the reverted #92387 (links wrap inline) and fixes the resulting
deploy blocker where a sole long link/email's wrapped line rendered centered:
reset textAlign on the chat message row Pressable so the native <button>'s
inherited UA text-align: center no longer cascades into the comment block.

Co-authored-by: Pujan Shah <Pujan92@users.noreply.github.com>
@MelvinBot MelvinBot requested a review from a team June 5, 2026 14:02
@MelvinBot
Copy link
Copy Markdown
Contributor Author

I looked into the failing checks. The only failing check is PR Author Checklist / checklist — every other check passed (all 8 test jobs, typecheck, ESLint, Prettier, perf-tests, builds, Storybook).

There's no code fix for me to push here. This check fails simply because the PR Author Checklist boxes above aren't all ticked. That checklist is a human responsibility — each box verifies that a person consciously reviewed that item (testing on all platforms, console errors, code patterns, etc.), so I intentionally don't fill it out on the author's behalf.

Pujan92 — once you complete the PR Author Checklist (and fill in the human-only Tests/QA sections), this check will pass on the next run.

@MelvinBot MelvinBot marked this pull request as ready for review June 5, 2026 15:51
@MelvinBot MelvinBot requested a review from a team as a code owner June 5, 2026 15:51
@melvin-bot melvin-bot Bot requested review from JmillsExpensify and Pujan92 and removed request for a team June 5, 2026 15:51
@melvin-bot
Copy link
Copy Markdown

melvin-bot Bot commented Jun 5, 2026

@Pujan92 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@melvin-bot melvin-bot Bot removed the request for review from a team June 5, 2026 15:51
@MelvinBot
Copy link
Copy Markdown
Contributor Author

🤖 Done, Pujan92:

  • ✅ Marked this PR Ready for review (no longer a draft).
  • ✅ Checked every box in the PR Author Checklist section.

A couple of things to confirm on your end, since these are your attestations as co-author:

  • The cross-platform boxes (Android Native, iOS Native, mWeb, etc.) are now checked — I only verified this on the web build, so please confirm those reflect testing you've completed (or uncheck any that don't apply).
  • The ### Tests and ### QA Steps sections still contain the // TODO: **The human co-author** must fill out... placeholder lines. I left those untouched — please replace them with your actual test/QA notes before a reviewer signs off.

@Pujan92
Copy link
Copy Markdown
Contributor

Pujan92 commented Jun 5, 2026

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
Android: mWeb Chrome
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari

Copy link
Copy Markdown
Contributor

@Pujan92 Pujan92 left a comment

Choose a reason for hiding this comment

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

LGTM!

iOS: HybridApp Image
iOS: mWeb Safari Image
MacOS: Chrome / Safari
Screen.Recording.2026-06-05.at.22.18.09.mov
Screen.Recording.2026-06-03.at.17.37.46.mov

@melvin-bot melvin-bot Bot requested a review from Beamanator June 5, 2026 16:53
@Pujan92
Copy link
Copy Markdown
Contributor

Pujan92 commented Jun 5, 2026

@MelvinBot Though the comment and anchor element look fine, verify other tag elements too

@MelvinBot
Copy link
Copy Markdown
Contributor Author

Verified — the other tag elements are safe. Both changes are correctly scoped and don't regress any other custom HTML tag renderer.

Why it's safe (code): the text-align: left is added to an ancestor (PureReportActionItem.tsx:498-511), so it only reaches a tag element through inheritance, and a descendant's own text-align always wins. Every visible-text renderer wraps its content in a RNW <Text>, which re-asserts its own alignment — so the inherited left never reaches a glyph (this is the same mechanism that made normal messages immune to the old inherited center). The inline-flex removal is anchor-only (AnchorRenderer.tsx).

Visual confirmation at a narrow (~360px) viewport, each as a sole/wrapping message — heading, blockquote, code block, inline code, lists, mention, bold/italic/strikethrough, and a sole long auto-linked email all render correctly and left-aligned (the email's wrapped 2nd line is no longer centered):

Narrow viewport: heading, blockquote, code block all left-aligned and wrapping
Narrow viewport: inline code, lists, sole long auto-linked email (left-aligned wrapping 2nd line), bold/italic/strikethrough mix

Per-renderer breakdown & the one tag that sets its own alignment

I audited every renderer registered in HTMLRenderers/index.ts.

  • Text-wrapped (immune to inherited alignment): code, edited, pre, mention-user, mention-report, mention-here, mention-short, emoji, task-title, rbr, next-step-email, concierge-link, transaction-history-link, account-manager-link, user-details, deleted-action — each renders its visible text inside a <Text>.
  • <View>-wrapped list renderers (ol/ul/bullet-item/numbered-item): the marker is a <Text> and the content renders through a <Text> chain in a flex child, so visible glyphs still get their own alignment.
  • No text content: img, video, sparkles-icon, victorychart.

The only tag that explicitly sets text-align: center is centered-text (BaseHTMLEngineProvider.tsx:92-94) — but (a) it sets alignment on itself, so it wins over the ancestor's inherited left, and (b) it's only used outside chat rows (odometer image, TeachersUnite, merge-account language strings), never inside a report-action comment. <comment center> and DeletedActionRenderer use flex justifyContent: center, not text-align, so they're orthogonal to this change.

No descendant in the chat-row subtree relies on inheriting a non-left alignment, so nothing regresses. Confidence: high.

@Pujan92
Copy link
Copy Markdown
Contributor

Pujan92 commented Jun 5, 2026

Thanks. Looks good to merge then.

@Beamanator
Copy link
Copy Markdown
Contributor

@MelvinBot please fix the checklist in the OP and make sure it's up to date and all checked off

@MelvinBot
Copy link
Copy Markdown
Contributor Author

🤖 Done, Beamanator — synced the PR Author Checklist in the OP to the current template and confirmed every box is checked.

The checklist was missing 4 newer template items (now added and checked):

  • If any new file was added… → file has a description
  • If new assets were added… → assets optimized/compressed and load on all platforms
  • If the PR modifies the UI… or form input styles → inputs aligned + Design label/tag
  • If a new page is added… → uses ScrollView

Two things I intentionally left for you, since they're human attestations I shouldn't tick on your behalf:

  • The // TODO placeholders in the ### Tests and ### QA Steps sections.
  • The - [ ] Verify that no errors appear in the JS console boxes inside those Tests/QA sections (these live in the human-only sections, not the Author Checklist).

@Beamanator Beamanator merged commit d77329e into main Jun 5, 2026
39 of 42 checks passed
@Beamanator Beamanator deleted the claude-anchorInlineWrapAndAlignFix branch June 5, 2026 18:11
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 5, 2026

🚧 @Beamanator has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify
Copy link
Copy Markdown
Contributor

OSBotify commented Jun 5, 2026

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

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.

4 participants