Skip to content

feat(textbox): Touch/pen text selection flyout on Skia - #23852

Merged
Xiaoy312 merged 20 commits into
masterfrom
dev/xygu/20260720/text-selection-flyout
Jul 30, 2026
Merged

Xiaoy312 merged 20 commits into
masterfrom
dev/xygu/20260720/text-selection-flyout

Conversation

@Xiaoy312

@Xiaoy312 Xiaoy312 commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

GitHub Issue: Tracked internally (no public issue).

PR Type:

✨ Feature

What changed? 🚀

Brings the touch/pen text selection flyout on Skia in line with the mobile selection experience. Before, a touch/pen interaction on a TextBox/TextBlock did not reliably surface a usable selection flyout, and when it did the command set and chrome were off.

Gestures & selection

  • Open the selection flyout on insertion-handle tap — tapping the single insertion handle (collapsed caret, no selection) now opens the selection flyout, mirroring the native insertion-handle popup. This is an Uno addition beyond the WinUI port (which only shows the flyout for a non-empty selection).
  • Long-press flyout includes Cut/Copy — a touch long-press selects the word before the flyout computes its commands, so Cut/Copy are present. Fixes the inner DisplayBlock's ContextRequested firing with an empty selection.
  • Empty field: a tap places the caret — the touch tap-to-caret path was gated on non-empty text, so under the mobile (iOS/Android) conventions an empty TextBox showed no caret affordance at all — and on Android no insertion handle, hence no way to reach the flyout. A single tap now places the convention's caret, and deliberately does not open the flyout (that stays with the double-tap, the long-press and the handle tap).
  • Empty field: double-tap / long-press opens the flyout — both gesture paths dead-ended on an empty field: the release handler gated all touch-tap handling on non-empty text, and OnContextRequestedImpl suppressed the default context flyout before substituting TouchSelectWord/BeginTouchCaretDrag, which are no-ops with no text. Both now place the convention's collapsed caret and open the selection flyout over it (via the same allowEmptySelection hook the insertion-handle tap uses), matching the native mobile Paste popup. Scoped to the mobile conventions — the Desktop convention keeps opening its ContextFlyout through base OnContextRequestedImpl.
  • Pin gripper tap to the anchor index — a tap on a selection gripper no longer drifts the caret off the anchor.
  • Tapping a selection thumb keeps the selection — with a range selected (both thumbs showing), a tap on either thumb routed through the caret-placing path and collapsed the selection to length 0. A thumb is a selection edge, not a caret, so caret placement is now skipped while both thumbs show; the presenter still re-shows the selection flyout on release, and the single insertion handle keeps placing its caret.

Flyout commands & chrome

  • Select All is always offered on touch/pen — it now survives an empty TextBox, so a touch gesture there always has a command and opens a usable flyout. GetButtonsToAdd takes the touch/pen preference explicitly rather than reading InputDevicePrefersPrimaryCommands, which is only assigned in OnOpening: the pre-open HasTouchPrimaryCommandsFor gate and the post-open UpdateButtons must agree on the command set, or the gate would suppress the very flyout UpdateButtons was about to fill. Observable delta: an empty box with an empty clipboard now opens, with Select All as its lone primary command, where it previously stayed closed. PasswordBox is unchanged — its Select All still needs Password.Length > 0.
    • Two deliberate departures: WinUI drops Select All with no text, and native mobile shows only Paste on an empty field. An empty box — including a read-only one — therefore now opens a flyout whose Select All does nothing. IsReadOnly is not carved out: in GetTextBoxButtonsToAdd it gates the mutating commands only, and Copy/Select All sit outside it by design.
  • Never open a flyout that would immediately self-hide — a transient flyout whose primary bar is empty hides itself the moment it opens, flashing an empty popup. The new TextCommandBarFlyout.HasTouchPrimaryCommandsFor lets a touch/pen caller ask up-front whether opening is worth it; the caret is still placed when the answer is no. It tests the primary-bar mask rather than "any command", since secondary commands (Undo/Redo) don't prevent the self-hide. A custom SelectionFlyout is never suppressed — its commands can't be inspected.
  • Primary-bar command buttons show an icon + label — when Cut/Copy/Paste/Select All is the lone primary command of a transient touch/pen flyout, it can be hosted directly under the command bar instead of its PrimaryItemsControl, so the implicit CommandBarFlyoutAppBarButtonStyle never reaches it and the text label stays collapsed. A shared ApplyCommandBarFlyoutButtonStyle helper now assigns that style explicitly to all four, so every primary-bar command button carries the flyout template regardless of hosting. This is a workaround — the underlying CommandBarFlyoutCommandBar hosting nondeterminism remains.
  • Re-style a button promoted out of the overflow — CommandBarOverflowPresenter clears StyleProperty as an item leaves the overflow, so a button first realized as a secondary command (e.g. Select All while a full selection stands) fell back to the default AppBarButton template — no PrimaryLabelStates, collapsed label. The flyout style is re-applied on GetButton's cached-return path, before the button is re-realized in the primary bar (a no-op when already styled, so the never-overflowed path is unchanged).
  • Don't auto-open the proofing menu on the overflow tap — in a touch selection flyout the proofing button loads only once the user taps the overflow ("..."), and WinUI's auto-open then hijacked that tap by opening the spelling-suggestions submenu. The show mode and input device are now captured at open time — the CommandBar's Opened handler flips a Transient flyout's live ShowMode to Standard on expand, so the live value can't discriminate — and the auto-open is suppressed only for a touch-driven selection flyout. Context menus (Standard) still auto-open, and pen/mouse keep the WinUI default.
  • Hide the overflow ("...") button when there is no overflow — for the touch/pen text flyout with no secondary commands, the overflow button is collapsed instead of dangling over an empty menu. WinUI's default (Auto) is preserved for mouse/keyboard and for general CommandBarFlyout (native WinUI does show the "..." there — verified on WinAppSDK — so that behavior is intentionally left unchanged).

Touched areas: TextCommandBarFlyout, FlyoutBase (new WasOpenedByTouch), TextBox/TextBlock Skia pointer & selection handling, TextSelectionGripperPresenter, and UIElement.ContextRequested.

Runtime tests cover each gesture for both mobile conventions (tap / double-tap / long-press, empty and non-empty), the gripper and thumb taps, PasswordBox as the inherited path, the empty-clipboard cases, the primary-bar labels including the overflow→primary promotion, and the proofing auto-open suppression. The empty-clipboard tests count Opened rather than checking IsOpen, since IsOpen cannot distinguish "never opened" from "opened then self-hid"; the thumb-tap tests deliver the tap through the gripper host seam rather than at the thumb's coordinates, because grippers live in popups clipped to the TextBox and a coordinate-aimed tap can silently land on the text — a false pass.

PR Checklist ✅

Xiaoy312 and others added 7 commits July 22, 2026 17:27
On a touch long-press over a TextBox, the ContextRequested event
originates on the inner DisplayBlock and bubbles up. Class handlers run
at every ancestor regardless of Handled, so the DisplayBlock's handler
(OnContextRequestedCore, via the OwningTextBox redirect) opened the
owning control's ContextFlyout with an empty selection - computing its
commands before TextBox.OnContextRequestedImpl selected the word. On a
mobile convention the flyout showed only Paste / Select All.

Defer the DisplayBlock case: return early and let the event bubble to
the owning TextBox's class handler, which applies the touch-selection
convention (select word first) before showing the appropriate flyout.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Tapping a touch-selection gripper re-sampled the finger point, which sits on the thumb below the caret line, so on a single-line box GetIndexAt spilled onto the line below and jumped the caret to the end of the text (the Android insertion handle). Pin the tap to the gripper's own anchor index instead, mirroring the drag path's GrabOffsetY correction. A TextBlock keeps its selection on a gripper tap.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Tapping the single insertion handle (EndOnly gripper) now re-opens the
selection flyout (Paste / Select all) even over a collapsed caret,
mirroring the native iOS/Android insertion-handle popup. A new
allowEmptySelection flag on QueueGripperSelectionFlyout feeds the touch
branch of UpdateSelectionFlyoutVisibility; a gripper tap sets it, a drag
does not. Gated to the iOS/Android touch conventions at the TextBox host
boundary, so Desktop keeps the WinUI-port behavior of showing the flyout
only for a non-empty selection.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
TextCommandBarFlyout self-hides a transient flyout that has no primary
commands. Over a collapsed caret, Select All was only ever a secondary
command, so with an empty clipboard (no Paste) the insertion-handle
flyout had zero primary commands and immediately closed itself.

Promote Select All to a primary command for the touch/pen
collapsed-caret TextBox case so the flyout always opens, matching the
native mobile insertion popup. Desktop (mouse) and the existing
selection flyout (SelectionLength > 0) are unchanged.

The runtime test now clears the clipboard and polls CanPasteClipboardContent
so it deterministically covers this case; it previously passed only
against a non-empty ambient clipboard.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
When the insertion-handle flyout routes Select All into the primary bar (so a transient flyout keeps a primary command and stays open), show it like Cut/Copy/Paste with an icon + label. Restore the icon its command clears, and clear it again when the cached button routes back to the text-only overflow menu.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
When Select All is promoted to the primary bar of a transient insertion-caret flyout, it can be hosted directly under the command bar rather than its PrimaryItemsControl, so the implicit CommandBarFlyoutAppBarButtonStyle never reaches it and its text label stays collapsed. Assign that style explicitly so the button always carries the flyout template, matching Cut/Copy/Paste.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The base CommandBar shows the "..." overflow button whenever the primary
bar is taller than the compact height (labelled commands), even with an
empty overflow. On the touch/pen text selection flyout that dangles a
"..." over an empty menu — most visibly the insertion-caret flyout where
Select All is promoted to the primary bar and nothing is secondary.

Gate the overflow button on the actual secondary-command count for the
touch/pen text flyout only, keeping WinUI's default (Auto) for
mouse/keyboard and for general CommandBarFlyout (native WinUI does show
the "..." there — verified on WinAppSDK — so that stays as-is).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings July 23, 2026 00:05
@github-actions github-actions Bot added the area/skia ✏️ Categorizes an issue or PR as relevant to Skia label Jul 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves Skia touch/pen text-selection UX so TextBox/TextBlock selection grippers and the text command flyout behave more like mobile (iOS/Android) conventions, including reopening the flyout on insertion-handle taps and preventing caret/selection drift when tapping grippers.

Changes:

  • Adjusts Skia context-request handling so the owning TextBox commits touch selection before command computation (so Cut/Copy appear on long-press).
  • Updates gripper-tap handling to pin actions to the gripper’s selection edge/caret index and enables reopening the selection flyout over a collapsed caret (mobile conventions only).
  • Tweaks TextCommandBarFlyout command placement/visuals for the “collapsed caret + empty clipboard” scenario and adds runtime-test coverage for the regressions.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Uno.UI/UI/Xaml/UIElement.ContextRequested.cs Defers context flyout handling for TextBox/PasswordBox inner DisplayBlock so selection is committed before command computation.
src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.skia.cs Adds Skia-only selection-flyout gating to allow transient flyout over collapsed caret when insertion handle is tapped; pins gripper tap to anchor index.
src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.pointers.skia.cs Refactors touch tap/word-select paths to allow index-based selection updates reused by gripper taps.
src/Uno.UI/UI/Xaml/Controls/TextBlock/TextBlock.skia.cs Updates TextBlock gripper-tap behavior to preserve selection and re-show grippers.
src/Uno.UI/UI/Xaml/Controls/Primitives/TextSelectionGripperPresenter.skia.cs Extends gripper host contract to pass an anchor index and allow empty-selection flyout reopening on tap.
src/Uno.UI/UI/Xaml/Controls/CommandBarFlyout/TextCommandBarFlyout.mux.cs Promotes Select All to primary commands for insertion-caret flyout and collapses overflow button when there’s no secondary content.
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.skia.cs Adds Skia runtime tests covering insertion-handle tap caret stability, insertion-handle flyout opening with empty clipboard, and long-press Cut/Copy availability.
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBlock.cs Adds runtime test ensuring tapping a selection gripper doesn’t reselect a different word (selection stays stable).
Comments suppressed due to low confidence (1)

src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.skia.cs:5428

  • The fixed Task.Delay(150) after releasing the long-press can be timing-dependent. Waiting for either the SelectionFlyout or ContextFlyout to actually open will reduce flakiness and avoid adding arbitrary delays to the runtime test suite.
			await WindowHelper.WaitForIdle();
			await Task.Delay(150);
			await WindowHelper.WaitForIdle();

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@unodevops

Copy link
Copy Markdown
Contributor

Xiaoy312 and others added 2 commits July 22, 2026 20:56
The cached Select All button re-allocated a SymbolIcon on every
UpdateButtons run while in the primary bar. Reuse the existing icon
(allocate once) and only clear it when routing back to the text-only
overflow. Addresses PR review feedback.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Replace fixed Task.Delay waits for the dispatcher-queued flyout with
WindowHelper.WaitFor on the flyout's open state, and narrow nullable
flyout/label/command-bar locals via pattern-match guards so the
assertions are provably non-null. Addresses PR review feedback.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings July 23, 2026 00:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.skia.cs:5490

  • This test uses a fixed Task.Delay(150) to wait for the context flyout to open after right-click. Fixed delays make the test timing-dependent and can be flaky/slower on CI.

Prefer waiting on the actual condition (flyout IsOpen) via WindowHelper.WaitFor, consistent with the other flyout-opening tests in this file.

			await WindowHelper.WaitForIdle();
			await Task.Delay(150);
			await WindowHelper.WaitForIdle();

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 223738 found UI Test snapshots differences: skia-linux-screenshots: 57, skia-windows-screenshots: 2348, wasm: 11

Details
  • skia-linux-screenshots: 57 changed over 2348

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Buttons.png
    • ContextRequested.png-dark
    • ContextRequested.png
    • ClipboardTests.png-dark
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • Gamepad_Enumeration.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • DisplayInformation.png-dark
    • Examples.png-dark
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
  • skia-windows-screenshots: 2348 changed over 2392

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedIconPage.png-dark
    • ApplicationViewSizing.png
    • AppWindowPresenters.png-dark
    • ArcSegment.png
    • AutoBorderStretchwithrightmargin.png
    • AutoSuggestBox_Description.png
    • BackGesture.png
    • BasicAutoSuggestBox.png-dark
    • BasicThemeResources.png-dark
    • BasicThemeResources.png
    • BorderTopwithmargins.png
    • BorderVersusPanelClipping.png-dark
    • Border_CornerRadius_Binding.png-dark
    • Border_CornerRadius_Binding.png
    • Border_Corner_Overlap.png-dark
    • Border_Corner_Overlap.png
    • Border_With_CompositeTransform.png-dark
    • Border_With_CompositeTransform.png
    • Brushes_ImplicitConvert.png-dark
    • Brushes_ImplicitConvert.png
  • wasm: 11 changed over 1076

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • UITests.Uno_Web.Http.CookieManagerTests
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Ogg_Extension
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListViewSelectedItems
    • UITests.Windows_UI_Xaml_Controls.CalendarView.CalendarView_Theming
    • SamplesApp.Wasm.Windows_UI_Xaml_Controls.ListView.ListView_IsSelected
    • UITests.Windows_UI_Xaml_Media_Animation.ColorAnimation_Background
    • UITests.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_NavigationProperties
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Minimal
    • Uno.UI.Samples.Content.UITests.WebView.WebView_AnchorNavigation
    • SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_EnableDevTools
    • UITests.Shared.Microsoft_UI_Xaml_Controls.ExpanderTests.WinUIExpanderPage

Xiaoy312 and others added 7 commits July 23, 2026 10:17
When Paste is the lone primary command of a touch/pen text command flyout
(an empty editable TextBox with clipboard content), it can be hosted directly
under the command bar instead of its PrimaryItemsControl, so the implicit
CommandBarFlyoutAppBarButtonStyle never reaches it and its text label stays
collapsed. Factor the Select All style workaround into a shared
ApplyCommandBarFlyoutButtonStyle helper and apply it to Cut/Copy/Paste as
well, so every primary-bar command button carries the flyout template
regardless of hosting. Extends the Select All workaround; the underlying
CommandBarFlyoutCommandBar hosting nondeterminism remains.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
A CommandBarFlyout command button first realized in the overflow (a
secondary command, e.g. Select All while a full selection stands) loses
its explicitly-assigned CommandBarFlyoutAppBarButtonStyle when promoted
to the primary bar on caret-collapse: CommandBarOverflowPresenter clears
StyleProperty as the item leaves the overflow, so the button falls back
to the default AppBarButton template (no PrimaryLabelStates) and its
text label stays collapsed.

Re-apply the flyout style on GetButton's cached-return path for
Cut/Copy/Paste/Select All, before the button is re-realized in the
primary bar. No-op when already styled, so the never-overflowed path is
unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
In a touch selection flyout the proofing button loads only when the
user taps the overflow ("..."), and the WinUI auto-open then hijacked
that tap by opening the spelling-suggestions submenu.

Capture the show mode and input device at open time (the CommandBar's
Opened handler flips a Transient flyout's live ShowMode to Standard on
expand, so the live value can't discriminate) and suppress the auto-open
only for a touch-driven selection flyout. Context menus (Standard) still
auto-open, and pen/mouse keep the WinUI default.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Under the mobile (iOS/Android) touch conventions, a double-tap or
long-press in an empty TextBox did nothing at all. Both gesture paths
dead-ended: OnPointerReleasedPartial gated its whole touch-tap handling
on non-empty text, and OnContextRequestedImpl suppressed the default
context flyout (args.Handled = true) before substituting TouchSelectWord
/ BeginTouchCaretDrag, which are no-ops with no text.

Both now route to HandleEmptyTextTouchGesture, which places the
convention's collapsed caret and opens the selection flyout over it via
the existing allowEmptySelection hook (as the insertion-handle tap
already does), matching the native mobile Paste popup.

Scoped to the mobile conventions: the Desktop convention already opens
its ContextFlyout through base OnContextRequestedImpl, and Desktop is
likewise excluded from the empty-selection flyout in
QueueGripperSelectionFlyout.

An empty field offers no Cut/Copy/Select All, so with an empty clipboard
the flyout has no primary command and TextCommandBarFlyout hides itself
the moment it opens - flashing an empty popup. Gate on the new
TextCommandBarFlyout.HasTouchPrimaryCommandsFor so it is never opened in
that state; the caret is still placed. The gate tests the primary-bar
mask rather than "any command", since a transient flyout self-hides on an
empty primary bar regardless of secondary commands (Undo/Redo). A custom
SelectionFlyout is never suppressed - its commands can't be inspected.

Runtime tests cover double-tap and long-press for both conventions, an
empty PasswordBox (same inherited path), and the empty-clipboard case.
The last one counts Opened rather than checking IsOpen, since IsOpen
cannot distinguish "never opened" from "opened then self-hid".

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
With a range selected under the mobile touch conventions (both thumbs
showing), tapping either thumb collapsed the selection to length 0. A
gripper tap routes through OnGripperTapped, whose single-tap branch
called TouchTapAt - the caret-placing path - so a stray tap on a thumb
wiped the user's selection.

A thumb is a selection edge, not a caret: skip the caret placement while
both thumbs are showing and leave the selection alone. The presenter
still re-shows the selection flyout on release, and the insertion-handle
(EndOnly) case is unaffected - it keeps placing its caret.

When_Touch_SelectAll_Overflow_Then_Tap_Left_Thumb_Flyout_Shows_SelectAll_Label
relied on the collapse to promote Select All from the overflow to the
primary bar, so it now reaches that state with a plain tap in the text
(which does collapse the selection, per native Android) followed by an
insertion-handle tap, and is renamed accordingly.

The new tests deliver the tap through the gripper host seam rather than
injecting at the thumb's coordinates: grippers live in popups clipped to
the TextBox, so in the short test host the thumb hangs outside the
control and a coordinate-aimed tap silently lands on the text - or on
nothing at all, which is a false pass.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Under the mobile touch conventions a single tap in an empty TextBox was
swallowed: the touch tap-to-caret path is gated on non-empty text, so the
field showed no caret affordance at all. On Android that also meant no
insertion handle, and so no way to reach the flyout - the handle tap is
what opens it over a collapsed caret.

Place the convention's caret on that tap. A single tap deliberately does
NOT open the flyout; that stays with the double-tap, the long-press and
the handle tap.

The observable gap was Android's insertion handle. iOS already got its
bare caret from focus, so the iOS test is a parity guard rather than a
repro - it passes with and without this change.

Taps on the empty area of a NON-empty field were verified to already
behave correctly and are untouched: to the right of the text and below it
in a multiline box, both conventions place the caret at the nearest index
(and the Desktop convention selects the nearest word).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
On touch/pen, Select All is now available on a TextBox even when it holds
no text, so a touch gesture on an empty box always has a command and
opens a usable flyout instead of nothing.

GetButtonsToAdd now takes the touch/pen preference explicitly rather than
reading InputDevicePrefersPrimaryCommands, which is only assigned in
OnOpening: the pre-open HasTouchPrimaryCommandsFor gate and the
post-open UpdateButtons must agree on the command set, or the gate would
suppress the very flyout UpdateButtons was about to fill.

Two deliberate departures: WinUI drops Select All with no text, and
native mobile shows only Paste on an empty field. An empty box (including
a read-only one) therefore now opens a flyout whose Select All does
nothing. IsReadOnly is not carved out - in this method it gates the
mutating commands only, and Copy/Select All sit outside it by design.

PasswordBox is unchanged: its Select All still needs Password.Length > 0.

Test fallout, all consequences of the above:
- The empty-box gesture tests now expect Select All, and the
  empty-clipboard case opens with Select All as its lone primary command
  instead of staying closed.
- A new empty PasswordBox + empty clipboard test keeps
  HasTouchPrimaryCommandsFor covered; after this change that gate can no
  longer return false for a TextBox, so a PasswordBox is the only
  remaining case that exercises it (including its Opened-count check
  that separates "never opened" from "opened then self-hid").
- When_Touch_Paste_Only_Flyout_Shows_Label moves to a PasswordBox. It
  guards the lone-primary hosting bug that collapses a button's label,
  and a TextBox can no longer reach a lone-primary bar on touch.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings July 27, 2026 19:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.skia.cs:6263

  • The test uses a fixed Task.Delay(150) after right-click to wait for the ContextFlyout to open. This is timing-dependent and can be flaky on slower CI machines; prefer waiting on the actual flyout open condition (similar to other tests in this file).
			await WindowHelper.WaitForIdle();
			await Task.Delay(150);
			await WindowHelper.WaitForIdle();

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 224362 found UI Test snapshots differences: skia-linux-screenshots: 57, skia-windows-screenshots: 2348, wasm: 11

Details
  • skia-linux-screenshots: 57 changed over 2348

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • Examples.png-dark
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • ClipboardTests.png-dark
    • DisplayInformation.png-dark
    • Focus_FocusVisual_Properties.png-dark
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • ContextRequested.png-dark
    • ContextRequested.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • Gamepad_Enumeration.png
    • ImageIconPage.png-dark
  • skia-windows-screenshots: 2348 changed over 2392

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AppBarButtonWithIconTest.png
    • AppBarToggleButtonTest.png
    • AppBar_KeyBoard.png
    • Accessibility_ScreenReader.png
    • AutoSizedPathCentered.png
    • Accessibility_ScreenReader.png-dark
    • AppWindowFeatures.png
    • AppWindowPresenters.png-dark
    • AppWindowPresenters.png
    • ApplicationViewMode.png-dark
    • BadgeNotificationTests.png-dark
    • ApplicationViewMode.png
    • Attributed_text_FontSize_Changing.png
    • Attributed_text_Simple.png-dark
    • AuthenticationBroker_Demo.png
    • AppXamlDefinedResources.png
    • Basics Pivot Test.png
    • ArcSegment.png-dark
    • AutomationPropertiesExtensions_Role.png
    • AutoBorderStretchwithbottommargin.png
  • wasm: 11 changed over 1076

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • SamplesApp.Wasm.Windows_UI_Xaml_Controls.ListView.ListView_IsSelected
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListViewSelectedItems
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Ogg_Extension
    • UITests.Windows_UI_Xaml_Media_Animation.ColorAnimation_Background
    • UITests.Shared.Microsoft_UI_Xaml_Controls.ExpanderTests.WinUIExpanderPage
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Minimal
    • UITests.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_NavigationProperties
    • UITests.Uno_Web.Http.CookieManagerTests
    • Uno.UI.Samples.Content.UITests.WebView.WebView_AnchorNavigation
    • SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_EnableDevTools
    • UITests.Windows_UI_Xaml_Controls.CalendarView.CalendarView_Theming

Xiaoy312 and others added 2 commits July 28, 2026 15:52
Invoking Copy on a touch/pen-opened text flyout left it hovering over the
text. CommandBarFlyout wires "close on invoke" onto its secondary
commands only (MUX extends that to the proofing menu, "same as
interactions with secondary commands"), but UpdateButtons routes
Cut/Copy/Paste into the primary bar for touch/pen, and a primary
AppBarButton click only reaches CommandBar.OnCommandExecutionStatic,
which collapses the overflow and never hides the flyout.

Cut and Paste appeared to work only by accident: they change the text, and
OnTextChangedPartial closes the selection flyout. Copy mutates nothing, so
nothing closed it. All three now close explicitly, which also covers the
targets that have no such accident - TextBlock, RichTextBlock,
RichTextBlockOverflow, RichEditBox and PasswordBox.

This replaces the UpdateButtons() refresh at those three sites rather than
adding to it. That call was reachable only in this same touch/pen
primary-bar case, so the pointer path is untouched: with a mouse the three
buttons are secondary, IsButtonInPrimaryCommands is false, and they close
through the existing secondary hook. Select All keeps its refresh on
purpose - it is promoted to the primary bar over a collapsed caret, and
after selecting it should re-render with Cut/Copy rather than close.

The device check on the gate is redundant with primary-bar membership
(only touch/pen puts these buttons there, and UpdateButtons rebuilds both
collections on every open, so nothing carries over). It is kept so the
scope reads locally as touch/pen - which is wider than mobile, as a
touchscreen or pen on desktop hits the same path.

The new touch test fails before this change ("invoking Copy should close
the touch selection flyout") and passes after. Its mouse counterpart pins
the untouched path: Cut/Copy/Paste absent from the primary bar, and the
overflow Copy still closing the flyout. Both invoke the button through
AppBarButton.OnClick via its automation peer instead of hit-testing
coordinates inside the popup.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The comment claimed an empty field offers no Select All, which stopped
being true when Select All became always-available on touch: a TextBox now
always carries it in the primary bar, so the gate below can no longer
return false for one.

State the case that still reaches it - a PasswordBox, whose Select All
needs a password and stays in the overflow either way, so an empty one
with an empty clipboard has no primary command to show.

Comment only; no behavior change.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings July 28, 2026 21:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.pointers.skia.cs:287

  • TouchTap takes a wasFocused parameter but doesn't use it. This is misleading for future maintenance (it suggests focus affects the tap behavior when it currently does not). Consider renaming the unused parameter to _ to make the intent explicit, or reintroduce its use if focus is meant to affect Desktop-convention tap semantics.
	private void TouchTap(Point point, bool wasFocused)
		=> TouchTapAt(Math.Max(0, TextBoxView.DisplayBlock.ParsedText.GetIndexAt(point, true, true)));

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 224622 found UI Test snapshots differences: skia-linux-screenshots: 57, skia-windows-screenshots: 2348, wasm: 11

Details
  • skia-linux-screenshots: 57 changed over 2348

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • DisplayInformation.png-dark
    • Buttons.png-dark
    • Buttons.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ContextRequested.png-dark
    • Examples.png-dark
    • ContextRequested.png
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • Focus_FocusVisual_Properties.png-dark
    • ClipboardTests.png-dark
    • ImageIconPage.png-dark
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
  • skia-windows-screenshots: 2348 changed over 2392

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AppBarButtonWithIconTest.png-dark
    • AppWindowClosing.png-dark
    • ArcSegment.png-dark
    • AutoBorderStretchwithtopmargin.png
    • AutoSuggestBoxChosenSuggestion.png
    • BadgeNotificationTests.png
    • BasicThemeResources.png-dark
    • BitmapIcon_Monochromatic.png
    • BorderTopwithmargins.png-dark
    • BorderTopwithmargins.png
    • Border_CornerRadius_BorderThickness.png
    • Border_CornerRadius_Clipping.png-dark
    • Border_Simple_No_Background_With_TextBox.png-dark
    • Border_Simple_No_Background_With_TextBox.png
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Canvas_With_Outer_Clip.png
    • Canvas_ZIndex.png-dark
    • CheckBox_IsEnabled_Automated.png-dark
    • CheckBox_IsEnabled_Automated.png
  • wasm: 11 changed over 1076

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListViewSelectedItems
    • UITests.Shared.Microsoft_UI_Xaml_Controls.ExpanderTests.WinUIExpanderPage
    • UITests.Windows_UI_Xaml_Media_Animation.ColorAnimation_Background
    • UITests.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_NavigationProperties
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Minimal
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Ogg_Extension
    • UITests.Uno_Web.Http.CookieManagerTests
    • UITests.Windows_UI_Xaml_Controls.CalendarView.CalendarView_Theming
    • Uno.UI.Samples.Content.UITests.WebView.WebView_AnchorNavigation
    • SamplesApp.Wasm.Windows_UI_Xaml_Controls.ListView.ListView_IsSelected
    • SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_EnableDevTools

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 224622 has failed on Uno.UI - CI.

Xiaoy312 and others added 2 commits July 29, 2026 11:12
Five touch flyout tests failed about half the time on macOS Desktop Skia
only. Build 224362 took eight macOS attempts to go green, roughly half the
remaining set clearing per retry.

The test budget equalled the platform poll interval.
MacOSClipboardExtension.SetContent is fire-and-forget, so the pasteboard
write lands a dispatcher turn later; CanPasteClipboardContent then only
refreshes from Clipboard.ContentChanged, which macOS raises from a 1s
NSTimer poll of NSPasteboard.changeCount (UNOClipboard.m); and the tests
waited on that property with WaitFor's default 1000ms. Windows and Linux do
not poll, so no other shard ever flaked.

Seed the clipboard before focusing instead: focusing runs a live
Clipboard.GetContent() via UpdateCanPasteClipboardContent, so the poll
leaves the critical path entirely and the property can be asserted rather
than waited on. The pre-existing read-only paste test already used this
seed-then-focus order.

SetClipboardText clears first and waits for the OS clipboard to go empty
then non-empty, so stale text from a prior test cannot satisfy it. A late
poll tick mid-gesture is harmless: OnClipboardContentChanged only does a
live-read property refresh, with no UpdateButtons or flyout interaction.

Verified 11/11 on Skia Desktop Windows. Windows has no clipboard poll, so
that proves no regression, not that the macOS flake is gone - the tell is
the macOS stage going green on attempt 1 rather than after 8.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
When_RightClick_Flyout_Copy_Closes_Flyout failed on the iOS Skia shard:
SelectedText was empty after invoking Copy, so "the selection should
survive Copy" tripped. It reproduced when retried in isolation.

This PR did not introduce that. HideAfterPrimaryBarInvoke only fires when
IsButtonInPrimaryCommands(button) is true, and the test itself asserts
Cut/Copy/Paste never reach PrimaryCommands on a mouse-opened flyout. The
same branch previously guarded an UpdateButtons() call, so for a mouse the
Copy path is unchanged. The collapse is pre-existing Skia-iOS behavior that
a new test merely exposed - ForceFocusLoss (which the flyout close does
call) and the iOS EndImeSession were both inspected and neither touches the
selection, so the mechanism is still unnamed and wants its own repro.

Both right-click tests inject a mouse yet were only excluded on SkiaWasm,
so they ran on Skia-iOS and Skia-Android where a mouse is not the real
input device and the default touch selection convention is mobile. Gate
them the way their touch counterpart already is - Desktop for dev plus real
Android. When_RightClick_Over_Selection_Flyout_Includes_Copy is green today
(it only checks command availability, never selection survival) and is
included for consistency.

Verified 3/3 on Skia Desktop Windows, confirming SkiaDesktop still covers
the Win32 host rather than silently skipping.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings July 29, 2026 15:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

src/Uno.UI/UI/Xaml/Controls/TextBox/TextBox.skia.cs:1940

  • QueueGripperSelectionFlyout can enable the empty-selection flyout on insertion-handle tap without checking whether the touch primary command bar would actually have any commands. For an empty PasswordBox with an empty clipboard, this will still open a transient TextCommandBarFlyout that immediately self-hides in its Opened handler (PrimaryCommands/SecondaryCommands empty), causing a visible flash. Consider reusing HasTouchPrimaryCommandsFor (as in HandleEmptyTextTouchGesture) when allowEmptySelection is requested over a collapsed caret, and only then pass allowEmptySelection through.
	void ITextSelectionGripperHost.QueueGripperSelectionFlyout(PointerRoutedEventArgs args, bool allowEmptySelection)
		=> QueueUpdateSelectionFlyoutVisibility(
			args.Pointer.PointerDeviceType,
			args.GetCurrentPoint(this).Position,
			// The single insertion handle only exists under the mobile (iOS/Android) conventions; tapping it
			// re-opens the flyout even over a collapsed caret. Desktop never gets the empty-selection flyout.
			allowEmptySelection: allowEmptySelection && TouchSelectionConvention != TouchTextSelectionConvention.Desktop);

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 224769 found UI Test snapshots differences: skia-linux-screenshots: 57, skia-windows-screenshots: 2348, wasm: 11

Details
  • skia-linux-screenshots: 57 changed over 2348

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • ContextRequested.png-dark
    • ContextRequested.png
    • Buttons.png-dark
    • Buttons.png
    • DisplayInformation.png-dark
    • Examples.png-dark
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • ElementLevelTheme.png-dark
    • ExpanderColorValidationPage.png
    • ElementLevelTheme.png
    • ClipboardTests.png-dark
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • Focus_FocusVisual_Properties.png-dark
    • ImageIconPage.png-dark
  • skia-windows-screenshots: 2348 changed over 2392

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AppBarButtonTest.png-dark
    • AnimatedIconPage.png-dark
    • ApplicationViewSpanningRectsPage.png-dark
    • ApplicationViewSizing.png
    • Attributed_text_Supserscript.png-dark
    • AppWindowPresenters.png-dark
    • AutomationPropertiesExtensions_Role.png
    • AutoSizedTopLeft.png
    • AutoSuggestBox_Icons.png-dark
    • BadgeNotificationTests.png-dark
    • BasicAutoSuggestBox.png-dark
    • Basics_Automated.png
    • Battery.png
    • BitmapIcon_Foreground.png-dark
    • BindableDrawerLayout_ChangePane.png-dark
    • BorderTopwithmargins.png-dark
    • BorderBottomwithmargins.png-dark
    • Border_BorderThickness.png
    • BorderBottomwithmargins.png
    • Border_Clipped_Change_Property.png-dark
  • wasm: 11 changed over 1076

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • UITests.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_NavigationProperties
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListViewSelectedItems
    • UITests.Shared.Microsoft_UI_Xaml_Controls.ExpanderTests.WinUIExpanderPage
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Ogg_Extension
    • UITests.Windows_UI_Xaml_Media_Animation.ColorAnimation_Background
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Minimal
    • SamplesApp.Wasm.Windows_UI_Xaml_Controls.ListView.ListView_IsSelected
    • UITests.Windows_UI_Xaml_Controls.CalendarView.CalendarView_Theming
    • UITests.Uno_Web.Http.CookieManagerTests
    • Uno.UI.Samples.Content.UITests.WebView.WebView_AnchorNavigation
    • SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_EnableDevTools

@Xiaoy312

Copy link
Copy Markdown
Contributor Author

@Xiaoy312
Xiaoy312 merged commit b1ece1d into master Jul 30, 2026
53 checks passed
@Xiaoy312
Xiaoy312 deleted the dev/xygu/20260720/text-selection-flyout branch July 30, 2026 20:23
@mergify

mergify Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/skia ✏️ Categorizes an issue or PR as relevant to Skia

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants