Fix #5028 / #5029: InteractionDialog popup overlaps target when rect straddles midline#5030
Merged
Merged
Conversation
…straddles vertical midline `showPopupDialogImpl` picked popup placement purely from which half of the screen the anchor rect sat in. When the rect straddled the midline, neither the "popup downwards" branch (`rect.bottom < availableHeight/2`) nor the "popup upwards" branch (`rect.y > availableHeight/2`) matched, and control fell into a "popup over aligned with top of rect" branch that set `y = rect.getY() + 3mm` -- drawing the popup ON TOP of the target. This produced two user-visible symptoms reported against the same code: - #5028: the popup covers the target Button (hiding the Close button in the reporter's screenshot) when the form is scrolled so the target lands near the vertical middle of the screen. - #5029: on the initial show the popup's arrow points UPWARDS instead of at the Close button, and only flips to the correct side once the form is scrolled. With the popup overlapping the target, `CSSBorder.Arrow` cannot pick a consistent direction (`cabsY` straddles `trackY..trackY+h`, so neither the `cabsY >= trackY + trackHeight` nor `cabsY + height <= trackY` check fires), and the arrow tip renders on the wrong edge. Fix: choose placement by available space instead of midline. Prefer whichever side fits the popup's preferred height; fall back to the side with more room when neither fits. The historical "over the rect" branches are kept as a last resort for the truly degenerate case where the rect fills the viewport top-to-bottom and there is literally no room either above or below it. Tests: - `maven/core-unittests/.../InteractionDialogTest`: two new unit tests pin the invariants for #5028 (popup must not overlap target) and #5029 (popup must land entirely above or below target so `CSSBorder.Arrow` can pick a direction). Both were verified to FAIL on the unmodified code with the exact overlap coordinates, and pass with the fix. - `tests/core/test/com/codename1/ui/InteractionDialogPopupTests5028.java`, `InteractionDialogPopupTests5029.java`: ant-side regression tests that drive the same scenarios through `showPopupDialog(Rectangle)` and `showPopupDialog(Component)` end-to-end. - `tests/core/test/com/codename1/ui/InteractionDialogPopupTests4991.java`: ant-side mirror of the existing `core-unittests` regression for PR #5011 / issue #4991 (full-width landscape anchor). The unit-test copy was painful to find when grepping the popup-regression tests directory; mirroring it keeps both copies discoverable. Full `core-unittests` suite: 2550 tests pass, 0 failures. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
✅ Continuous Quality ReportTest & Coverage
Static Analysis
Generated automatically by the PR CI workflow. |
Collaborator
Author
|
Compared 110 screenshots: 110 matched. Native Android coverage
✅ Native Android screenshot tests passed. Native Android coverage
Benchmark ResultsDetailed Performance Metrics
|
Collaborator
Author
|
Compared 110 screenshots: 110 matched. Benchmark Results
Build and Run Timing
Detailed Performance Metrics
|
Collaborator
Author
|
Compared 110 screenshots: 110 matched. Benchmark Results
Build and Run Timing
Detailed Performance Metrics
|
The three `tests/core/test/com/codename1/ui/InteractionDialogPopupTests*.java` files I added in the previous commit don't actually run in CI: - `pr.yml` calls `ant test-javase`, but the body of that target in `build.xml:87-97` is wrapped in `<!-- ... -->` -- effectively a no-op. - `ant.yml` runs `tests/all.sh` -> `tests/core.sh` which builds a cn1app archetype project from `tests/core/` and runs `mvn package`. Surefire enumerates the .class files but reports `Tests run: 0` for each -- these classes extend `AbstractTest` rather than JUnit so surefire finds no test methods, and the CN1 `TestRunner` that would invoke `runTest()` is not wired into the lifecycle. Verified the same on the latest master CI run: `RoundRectBorderTest`, `TestComponent2`, and other long-standing ant tests all report `Tests run: 0`, and `SideMenuHamburgerTests4895` doesn't appear at all. The two unit tests added to `maven/core-unittests/.../InteractionDialogTest` cover the same assertions and DO execute in CI (via the "Run Unit Tests" step in pr.yml: `mvn clean verify -DunitTests=true -pl core-unittests -am`). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
InteractionDialog.showPopupDialogImplso a popup anchored to a target whose rect straddles the vertical midline lands above or below the target instead of on top of it.core-unittestsand ant-side regression tests for InteractionDialog not positioned correctly when pointing to an element positioned roughly in the middle of the screen #5028 and InteractionDialog pointing in the wrong direction on initial show #5029.Root cause
showPopupDialogImplpicked popup placement purely from which half of the screen the anchor rect sat in:When the rect straddled the midline, neither of the first two branches matched, and control fell into the "popup over" branches that drew the popup on top of the target. Two user-visible symptoms reported against the same code:
CSSBorder.Arrowcannot pick a consistent direction (cabsYstraddlestrackY..trackY+h, so neither thecabsY >= trackY + trackHeightnorcabsY + height <= trackYcheck fires), and the arrow tip renders on the wrong edge.Fix
Choose placement by available space instead of midline:
spaceBelow >= prefHeight→ place below.spaceAbove >= prefHeight→ place above.The historical fallback branches are kept verbatim so the truly degenerate "no room either side" case still renders the popup somewhere visible rather than off-screen.
Test plan
mvn -pl core-unittests test -DunitTests -Dtest=InteractionDialogTest,PickerTest— 11 tests pass.showPopupDialogStraddlingMidlineDoesNotOverlapTarget,showPopupDialogArrowDirectionConsistentWithPlacement) fail without the fix with the exact overlap coordinates, e.g.#5028: popup [933..967) overlaps anchor [930..990), and pass with the fix.core-unittestssuite: 2550 tests pass, 0 failures.Fixes #5028.
Fixes #5029.
🤖 Generated with Claude Code