Repository navigation
Fix BpkTopNavBar Arabic title truncation and BpkSegmentedControl long labels - #2915
Conversation
The expanded and collapsed titles were wrap-content with maxLines = 1 and an ellipsis. For some Arabic strings the reported intrinsic width is smaller than the width the text needs, so the title was laid out too narrow and ellipsized even though there was plenty of room. Give the titles the full available width. Co-authored-by: OpenCode <noreply@opencode.ai>
Generated by 🚫 Danger Kotlin against 7f9120a |
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
2 open issues
What changed in this PR
Fixes an issue where BpkTopNavBar titles in Arabic (RTL) were being incorrectly ellipsized due to Compose intrinsic width measurement, by ensuring the title is measured against available width.
Changes:
- Apply
Modifier.fillMaxWidth()to expanded and collapsed titleBpkTextinBpkTopNavBarImpl. - Add Android instrumented tests verifying Arabic (RTL) and English (LTR) titles are not ellipsized.
| File | Description |
|---|---|
| backpack-compose/src/main/kotlin/net/skyscanner/backpack/compose/navigationbar/internal/BpkTopNavBarImpl.kt | Forces title text to measure within available width to prevent erroneous ellipsizing in RTL. |
| backpack-compose/src/androidTest/kotlin/net/skyscanner/backpack/compose/navigationbar/BpkTopNavBarTitleTest.kt | Adds coverage to ensure titles are not ellipsized for Arabic RTL and English LTR. |
Review effort: Lite
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
4 open issues
hasText(title)can match semantics nodes that don’t exposeSemanticsActions.GetTextLayoutResult… · New The implementation change appliesfillMaxWidth()to both the expanded title and the collapsed… · New The PR description mentions both expanded and collapsed titles were affected, but the test only…results.single()can throw if the node doesn't exposeGetTextLayoutResult(or if it returns 0 /…
Review effort: Lite
… room #trivial Every button got an equal share of the width, so a long label was ellipsized even when the other labels left space unused. When every label fits its equal share the layout is unchanged. Otherwise the width is shared by what each label needs, and labels that fit an equal share keep their full text. Co-authored-by: OpenCode <noreply@opencode.ai>
…nav bar title #trivial Co-authored-by: OpenCode <noreply@opencode.ai>
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
4 open issues
.toWidths()can divide by zero whensum()is 0 (e.g., very narrow constraints whereavailable… · New The PR title/description focuses on fixingBpkTopNavBartitle truncation, but this PR also… · New The measure policy relies on even/odd indices to distinguish buttons vs dividers. This is tightly… · New Givenavailablecan become 0 (e.g., extremely constrained width after subtracting divider… · New
4 resolved since last review
The implementation change appliesfillMaxWidth()to both the expanded title and the collapsed…hasText(title)can match semantics nodes that don’t exposeSemanticsActions.GetTextLayoutResult… The PR description mentions both expanded and collapsed titles were affected, but the test only…results.single()can throw if the node doesn't exposeGetTextLayoutResult(or if it returns 0 /…
Review effort: Lite
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
9 open issues
toWidthscan fail whensum()is 0 (e.g., all computed weights are 0), causing a… · New.toWidths()can divide by zero whensum()is 0 (e.g., very narrow constraints whereavailable…buttonWidth()is measuring the bounds of the Text node, not the segment/button container. This… · NewbuttonWidth()is measuring the bounds of the Text node, not the segment/button container. This… · New In the unbounded-width branch,widthis computed from content but is not constrained with… · New In the unbounded-width branch,widthis computed from content but is not constrained with… · New Givenavailablecan become 0 (e.g., extremely constrained width after subtracting divider… The measure policy relies on even/odd indices to distinguish buttons vs dividers. This is tightly… The PR title/description focuses on fixingBpkTopNavBartitle truncation, but this PR also…
Review effort: Lite
…ify children by layoutId #trivial - Return zero widths instead of throwing when no width is available - Tag buttons and dividers with layoutId instead of relying on child order - Constrain the unbounded-width result to the incoming constraints - Match the selectable node in the width assertions Co-authored-by: OpenCode <noreply@opencode.ai>
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
3 open issues
The remainder correction can change widths that should be treated as ‘fixed’ (e.g., short labels… · New There’s no unit test covering the fractional-share rounding case where the algorithm should keep… · NewdividerPlaceables.sumOf { it.width }is computed multiple times in the same measure pass. Storing… · New
9 resolved since last review
toWidthscan fail whensum()is 0 (e.g., all computed weights are 0), causing a….toWidths()can divide by zero whensum()is 0 (e.g., very narrow constraints whereavailable… In the unbounded-width branch,widthis computed from content but is not constrained with… In the unbounded-width branch,widthis computed from content but is not constrained with…buttonWidth()is measuring the bounds of the Text node, not the segment/button container. This…buttonWidth()is measuring the bounds of the Text node, not the segment/button container. This… Givenavailablecan become 0 (e.g., extremely constrained width after subtracting divider… The measure policy relies on even/odd indices to distinguish buttons vs dividers. This is tightly… The PR title/description focuses on fixingBpkTopNavBartitle truncation, but this PR also…
Review effort: Lite
…red width #trivial Co-authored-by: OpenCode <noreply@opencode.ai>
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
4 open issues
The remainder-distribution logic can fail to make the output sum tototalwhenremainderis… · New This assertion is likely to be flaky across densities/font rendering because it relies on raw… · New UsingmaxIntrinsicWidth()for every button on every measure pass can be expensive and Compose… · New The checkneeds[it] * unsettled <= remainingcan overflow for largeneeds/unsettledvalues.… · New
3 resolved since last review
Review effort: Lite
…n the checks #trivial - Only take a pixel back from elements that still have width when rounding - Compare against remaining / unsettled to avoid an integer overflow - Assert the buttons span the control using measured bounds instead of an assumed divider width Co-authored-by: OpenCode <noreply@opencode.ai>
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
6 open issues
The remainder-distribution logic can fail to make the output sum tototalwhenremainderis… The “equal widths” fast-path check usesequalShare = available / needs.size(floor), which can… · NewallNeeds(...): List<List<Int>>materializes every combination (and repeatedly concatenates lists… · New UsingmaxIntrinsicWidth()for every button on every measure pass can be expensive and Compose… This assertion is likely to be flaky across densities/font rendering because it relies on raw…Iterable.max()/min()are deprecated in newer Kotlin versions in favor ofmaxOrNull()/… · New
1 resolved since last review
Review effort: Lite
Replace the Row-style remainder correction with cumulative edge rounding. Widths always add up to the total and can never be negative, so no special cases are needed. Add sweep tests for the invariants. The 4-button snapshots may shift by 1px. Co-authored-by: OpenCode <noreply@opencode.ai>
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
6 open issues
BpkTopNavBarcommonly uses animated state (the implementation imports animation APIs), and these… · New The width allocation depends onmaxIntrinsicWidth(height). Intrinsic measurement in Compose is… · New These tests generate the full cartesian product ofneedscombinations viaallNeeds(...)… · NewallNeeds(...): List<List<Int>>materializes every combination (and repeatedly concatenates lists… The “equal widths” fast-path check usesequalShare = available / needs.size(floor), which can…Iterable.max()/min()are deprecated in newer Kotlin versions in favor ofmaxOrNull()/…
4 resolved since last review
The remainder-distribution logic can fail to make the output sum tototalwhenremainderis… UsingmaxIntrinsicWidth()for every button on every measure pass can be expensive and Compose… This assertion is likely to be flaky across densities/font rendering because it relies on raw… The checkneeds[it] * unsettled <= remainingcan overflow for largeneeds/unsettledvalues.…
Review effort: Lite
…am the test cases #trivial Co-authored-by: OpenCode <noreply@opencode.ai>
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
3 open issues
hasText(label) and isSelectable()is unlikely to match anything reliably because the selectable… · Newheight = constraints.maxHeightmakes the control always take the maximum allowed height, which… · New Dividers are measured withConstraints(maxHeight = height)(unbounded width), which can violate… · New
6 resolved since last review
These tests generate the full cartesian product ofneedscombinations viaallNeeds(...)… The width allocation depends onmaxIntrinsicWidth(height). Intrinsic measurement in Compose is…BpkTopNavBarcommonly uses animated state (the implementation imports animation APIs), and these…allNeeds(...): List<List<Int>>materializes every combination (and repeatedly concatenates lists… The “equal widths” fast-path check usesequalShare = available / needs.size(floor), which can…Iterable.max()/min()are deprecated in newer Kotlin versions in favor ofmaxOrNull()/…
Review effort: Lite
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
6 open issues
maxIntrinsicWidth(height)can be relatively expensive (intrinsics typically trigger extra layout… · New Dividers are measured withConstraints(maxHeight = height)(unbounded width), which can violate…height = constraints.maxHeightmakes the control always take the maximum allowed height, which…hasText(label) and isSelectable()is unlikely to match anything reliably because the selectable… This import appears unused in the file (the code usesfetchSemanticsNode().boundsInRoot, which is… · Newmax()/min()on collections are deprecated in modern Kotlin stdlib in favor ofmaxOrNull()/… · New
Review effort: Lite



Summary
Two text-truncation fixes found in the Skyscanner app's Search Control GC when it is shown in other languages.
Hin- und Rückflug).1. BpkTopNavBar title truncated for Arabic
Cause
The titles are wrap-content
BpkTextwithmaxLines = 1andTextOverflow.Ellipsis. For some Arabic strings the intrinsic width Compose reports is smaller than the width the text needs. Measured on an emulator withheading2in RTL forابحث عن رحلة:maxIntrinsicWidth= 454.5px, but the text wraps onto a second line whenmaxLinesis unlimited, and is ellipsized whenmaxLines = 1. The title is therefore laid out too narrow and showsابحث عن رح.... English titles are not affected.Fix
Modifier.fillMaxWidth()on the expanded and collapsed title texts, so they are laid out against the available width instead of the intrinsic width. A title that genuinely does not fit is still ellipsized.Screenshots
Changes
BpkTopNavBarImpl:fillMaxWidth()on both titlesBpkTopNavBarTitleTest(androidTest): an expanded Arabic title in RTL and an English title in LTR are not ellipsized2. BpkSegmentedControl truncating long labels
Cause
Every segment was a
Rowchild withweight(1f), so each got an equal share of the width. A label that needs more than its share is ellipsized even when the other labels use much less.Fix
BpkSegmentedControlImplnow uses a customLayoutinstead of theRow:The rounding follows
Row's weighted children, so the equal-width case is pixel-identical and the existing snapshots do not change. The public API is unchanged.Behaviour change to be aware of: segments are no longer always equal width when a label does not fit.
Screenshots
Changes
BpkSegmentedControlImpl: custom measure policy anddistributeSegmentWidthsBpkSegmentedControlWidthsTest(unit, 9 tests): the width distributionBpkSegmentedControlLabelsTest(androidTest, 5 tests): German labels at 343dp are not ellipsized, English labels keep equal widths, the longest label gets the most width, labels that cannot all fit still fill the control, and with one very long label only that one is ellipsizedTesting
Hin- und Rückflugellipsized) and pass with them on an API 37 emulatordetektpassesBpkTopNavBarTest(20),BpkNavBarTest,BpkModalTestandBpkSegmentedControlTest(14) snapshot tests pass with no changesBpkTextmay have the same intrinsic width mismatch. Only the nav bar title is changed here.Remember to include the following changes:
README.md(no API or documented behaviour change for the documented cases)