Repository navigation
feat(textbox): Touch/pen text selection flyout on Skia - #23852
Conversation
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]>
There was a problem hiding this comment.
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
TextBoxcommits 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
TextCommandBarFlyoutcommand 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.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23852/wasm-skia-net9/index.html |
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]>
There was a problem hiding this comment.
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();
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23852/wasm-skia-net9/index.html |
|
The build 223738 found UI Test snapshots differences: Details
|
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]>
There was a problem hiding this comment.
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();
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23852/wasm-skia-net9/index.html |
|
The build 224362 found UI Test snapshots differences: Details
|
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]>
There was a problem hiding this comment.
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
TouchTaptakes awasFocusedparameter 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)));
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23852/wasm-skia-net9/index.html |
|
The build 224622 found UI Test snapshots differences: Details
|
|
|
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]>
There was a problem hiding this comment.
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);
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23852/wasm-skia-net9/index.html |
|
The build 224769 found UI Test snapshots differences: Details
|
|
Tick the box to add this pull request to the merge queue (same as
|
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/TextBlockdid not reliably surface a usable selection flyout, and when it did the command set and chrome were off.Gestures & selection
DisplayBlock'sContextRequestedfiring with an empty selection.TextBoxshowed 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).OnContextRequestedImplsuppressed the default context flyout before substitutingTouchSelectWord/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 sameallowEmptySelectionhook the insertion-handle tap uses), matching the native mobile Paste popup. Scoped to the mobile conventions — the Desktop convention keeps opening itsContextFlyoutthrough baseOnContextRequestedImpl.Flyout commands & chrome
TextBox, so a touch gesture there always has a command and opens a usable flyout.GetButtonsToAddtakes the touch/pen preference explicitly rather than readingInputDevicePrefersPrimaryCommands, which is only assigned inOnOpening: the pre-openHasTouchPrimaryCommandsForgate and the post-openUpdateButtonsmust agree on the command set, or the gate would suppress the very flyoutUpdateButtonswas 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.PasswordBoxis unchanged — its Select All still needsPassword.Length > 0.IsReadOnlyis not carved out: inGetTextBoxButtonsToAddit gates the mutating commands only, and Copy/Select All sit outside it by design.TextCommandBarFlyout.HasTouchPrimaryCommandsForlets 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 customSelectionFlyoutis never suppressed — its commands can't be inspected.PrimaryItemsControl, so the implicitCommandBarFlyoutAppBarButtonStylenever reaches it and the text label stays collapsed. A sharedApplyCommandBarFlyoutButtonStylehelper 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 underlyingCommandBarFlyoutCommandBarhosting nondeterminism remains.CommandBarOverflowPresenterclearsStylePropertyas 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 defaultAppBarButtontemplate — noPrimaryLabelStates, collapsed label. The flyout style is re-applied onGetButton'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).CommandBar'sOpenedhandler flips aTransientflyout's liveShowModetoStandardon 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.Auto) is preserved for mouse/keyboard and for generalCommandBarFlyout(native WinUI does show the "..." there — verified on WinAppSDK — so that behavior is intentionally left unchanged).Touched areas:
TextCommandBarFlyout,FlyoutBase(newWasOpenedByTouch),TextBox/TextBlockSkia pointer & selection handling,TextSelectionGripperPresenter, andUIElement.ContextRequested.Runtime tests cover each gesture for both mobile conventions (tap / double-tap / long-press, empty and non-empty), the gripper and thumb taps,
PasswordBoxas 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 countOpenedrather than checkingIsOpen, sinceIsOpencannot 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 theTextBoxand a coordinate-aimed tap can silently land on the text — a false pass.PR Checklist ✅
Screenshots Compare Test Runresults.