)]}'
{
  "commit": "3ca38538ff9ee71ea1ccf35b0b67ff33667faf75",
  "tree": "2603c1e35591c33914607492bebb0fb03e213194",
  "parents": [
    "52ac8930b048c11cb42cbb7fb5520869a9f20604"
  ],
  "author": {
    "name": "Muhammad Kamel",
    "email": "mu7ammadkamel@hotmail.com",
    "time": "Fri Jul 31 02:21:08 2026 +0300"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Thu Jul 30 23:21:08 2026 +0000"
  },
  "message": "fix: text selection two handles directionality. (#179928)\n\nFixes #187799\n\nThis PR fixes an issue where text selection handles would render facing\nthe wrong direction when the text directionality differed from the\nambient directionality (e.g., selecting English (LTR) text within an\napplication set to Arabic (RTL)), and also when a single selection spans\nboth LTR and RTL runs.\n\nPreviously, `TextSelectionOverlay` determined the start and end handle\ntypes based primarily on the ambient `TextDirection` and the logical\nselection range. This caused handles to swap (pointing away from the\nselection) in mixed-directionality scenarios.\n\nThis change updates the logic in `_updateSelectionOverlay` to derive\neach handle\u0027s type from the **per-endpoint `TextDirection`** reported by\n`TextSelectionPoint.direction`, falling back to the render object\u0027s\n`textDirection` when an endpoint does not provide one:\n\n* Start handle: `TextDirection.ltr` → `TextSelectionHandleType.left`,\n`TextDirection.rtl` → `TextSelectionHandleType.right`.\n* End handle: `TextDirection.ltr` → `TextSelectionHandleType.right`,\n`TextDirection.rtl` → `TextSelectionHandleType.left`.\n\nBecause each endpoint is evaluated independently, selections that cross\na directionality boundary (e.g. `\"abc مرحبا\"`) get handle types that\nmatch the local direction at each end, so both handles continue to \"hug\"\nthe selection.\n\nOn iOS, UIKit conventionally keeps selection handles aligned with the\nfield\u0027s own direction rather than the per-endpoint direction. To\npreserve platform behavior, when `defaultTargetPlatform \u003d\u003d\nTargetPlatform.iOS` both handles use the render object\u0027s `textDirection`\ninstead of the endpoint directions.\n\nWhen a non-collapsed selection yields fewer than two endpoints (e.g. the\nselection is scrolled or clipped out of view), handle direction falls\nback to the field\u0027s `textDirection` instead of asserting.\n\nCollapsed selections continue to use `TextSelectionHandleType.collapsed`\nfor both handles and are unaffected by this change.\n\n**Tests added**\n\nAdded new tests in `text_selection_test.dart`:\n\nAndroid (`TargetPlatformVariant.only(TargetPlatform.android)`), driven\nby a table of `_DirectionalityTestCase`s that assert the endpoint\ndirections reported by `RenderEditable` and the handle types received by\na spy `TextSelectionControls`:\n\n* ambient LTR, English text\n* ambient RTL, English text\n* ambient RTL, Arabic text\n* ambient LTR, Arabic text\n* ambient LTR, mixed `\"abc مرحبا\"` (English then Arabic)\n* ambient RTL, mixed `\"abc مرحبا\"` (English then Arabic)\n\niOS (`TargetPlatformVariant.only(TargetPlatform.iOS)`):\n\n* Verifies that for the mixed `\"abc مرحبا\"` selection under ambient LTR,\nboth handles follow the field\u0027s `textDirection` (i.e. `left` / `right`)\nrather than the per-endpoint directions — exercising the\nUIKit-compatibility branch.\n\nThe new directionality tests set `selectAllOnFocus: false` explicitly\n(with an inline comment) because web CI defaults\n`EditableText.selectAllOnFocus` to `true`, which can select all text on\nfocus and prevent handle rebuilds in these tests.\n\n## Pre-launch Checklist\n\n- [x] I read the [Contributor Guide] and followed the process outlined\nthere for submitting PRs.\n- [x] I read the [Tree Hygiene] wiki page, which explains my\nresponsibilities.\n- [x] I read and followed the [Flutter Style Guide], including [Features\nwe expect every widget to implement].\n- [x] I signed the [CLA].\n- [x] I listed at least one issue that this PR fixes in the description\nabove.\n- [x] I updated/added relevant documentation (doc comments with `///`).\n- [x] I added new tests to check the change I am making, or this PR is\n[test-exempt].\n- [x] I followed the [breaking change policy] and added [Data Driven\nFixes] where supported.\n- [x] All existing and new tests are passing.\n\nIf you need help, consider asking for advice on the #hackers-new channel\non [Discord].\n\n**Note**: The Flutter team is currently trialing the use of [Gemini Code\nAssist for\nGitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).\nComments from the `gemini-code-assist` bot should not be taken as\nauthoritative feedback from the Flutter team. If you find its comments\nuseful you can update your code accordingly, but if you are unsure or\ndisagree with the feedback, please feel free to wait for a Flutter team\nmember\u0027s review for guidance on which automated comments should be\naddressed.\n\n\n![image_issue](https://github.com/user-attachments/assets/7de61b60-c1dd-44bb-a5c8-34ff5d451350)\n\n\u003c!-- Links --\u003e\n[Contributor Guide]:\nhttps://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview\n[Tree Hygiene]:\nhttps://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md\n[test-exempt]:\nhttps://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests\n[Flutter Style Guide]:\nhttps://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md\n[Features we expect every widget to implement]:\nhttps://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement\n[CLA]: https://cla.developers.google.com/\n[flutter/tests]: https://github.com/flutter/tests\n[breaking change policy]:\nhttps://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes\n[Discord]:\nhttps://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md\n[Data Driven Fixes]:\nhttps://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "05f696b37ce29f61ec6cf2c429702f1b7aea3d17",
      "old_mode": 33188,
      "old_path": "packages/flutter/lib/src/widgets/text_selection.dart",
      "new_id": "8daf1d9e54fc43c8c0e4d95f242ef2b540f77df5",
      "new_mode": 33188,
      "new_path": "packages/flutter/lib/src/widgets/text_selection.dart"
    },
    {
      "type": "modify",
      "old_id": "c631f4b240d41849dc0c63a0e409b486d55b9626",
      "old_mode": 33188,
      "old_path": "packages/flutter/test/widgets/editable_text_tester.dart",
      "new_id": "61c41298bd18552f10d0764bfe151c81a22c0a88",
      "new_mode": 33188,
      "new_path": "packages/flutter/test/widgets/editable_text_tester.dart"
    },
    {
      "type": "modify",
      "old_id": "193398bf24d69d61968de6449d62996b68783df1",
      "old_mode": 33188,
      "old_path": "packages/flutter/test/widgets/text_selection_test.dart",
      "new_id": "4c33ff6fadd0541b3233208302b5ff06a9f59f16",
      "new_mode": 33188,
      "new_path": "packages/flutter/test/widgets/text_selection_test.dart"
    }
  ]
}
