Skip to content

Add declarative IsHitTestVisible(bool) common element modifier - #810

Merged
Alexandre Zollinger Chohfi (azchohfi) merged 3 commits into
microsoft:mainfrom
nsreehari:nsreehari/issue-809-is-hit-test-visible
Jul 28, 2026
Merged

Alexandre Zollinger Chohfi (azchohfi) merged 3 commits into
microsoft:mainfrom
nsreehari:nsreehari/issue-809-is-hit-test-visible

Conversation

@nsreehari

Copy link
Copy Markdown
Contributor

Summary

Adds a declarative IsHitTestVisible(bool) modifier to the common element surface, filling the last gap among the sibling boolean/visual state modifiers (IsEnabled, IsTabStop, IsVisible, Opacity). Until now, opting an element out of pointer hit-testing required the imperative .Set(c => c.IsHitTestVisible = false) escape hatch.

Fixes #809.

Motivation

Reactor.Community.ReactorFlow's MiniMap renders pointer-transparent overlay layers (viewport rectangle, node thumbnails) that must not intercept pointer input destined for the interactive canvas underneath. Its last remaining .Set(...) escape hatch is a NonInteractive helper whose entire body is element.Set(c => c.IsHitTestVisible = false). A declarative modifier lets that helper be dropped and the property composed like any other element state.

What changed

Plumbing mirrors IsTabStop exactly:

  • src/Reactor/Core/Element.cs — added bool? IsHitTestVisible to ElementModifiers, folded into ModifiersEqual and Merge.
  • src/Reactor/Elements/ElementExtensions.cs — added public static T IsHitTestVisible<T>(this T el, bool isHitTestVisible = true) where T : Element next to IsTabStop, with matching XML-doc style.
  • src/Reactor/Core/Reconciler.cs — applies fe.IsHitTestVisible = value only when set and changed, next to where IsTabStop is applied.
  • tests/Reactor.Tests/ElementExtensionsCoverageTests.cs — added IsHitTestVisible_Sets_Modifier, mirroring IsEnabled_Sets_Modifier.
  • skills/reactor.api.txt + plugins/reactor/skills/reactor-dsl/references/reactor.api.txt — regenerated API index (UPDATE_API_INDEX=1).

Additive and back-compat: new optional modifier defaulting to true (the WinUI default); no existing signature or behavior changes. Recycle-safety is already covered — ElementPool clears UIElement.IsHitTestVisibleProperty on release (issue #162), so a recycled control cannot strand a stale false.

Validation

Built and tested on win-x64:

UPDATE_API_INDEX=1 dotnet test tests/Reactor.Tests \
  --filter "FullyQualifiedName~Tooling.ApiIndexGeneratorTests.Index_IsUpToDate" -r win-x64
# → regenerated both reactor.api.txt copies; Passed 1

dotnet test tests/Reactor.Tests \
  --filter "FullyQualifiedName~ElementExtensionsCoverageTests|FullyQualifiedName~Tooling.ApiIndexGeneratorTests" \
  -r win-x64 --no-build
# → Passed 63, Failed 0 (incl. IsHitTestVisible_Sets_Modifier and Index_IsUpToDate)

Build succeeded with 0 errors.

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

Adds a new declarative common-element modifier for UIElement.IsHitTestVisible, aligning it with the existing boolean/visual-state modifier surface (e.g., IsEnabled, IsTabStop, IsVisible, Opacity) and removing the need for imperative .Set(c => c.IsHitTestVisible = ...) for pointer-transparent overlays.

Changes:

  • Introduced ElementModifiers.IsHitTestVisible plumbing (equality + merge) and applied it in the reconciler only when set and changed.
  • Added fluent extension IsHitTestVisible(bool isHitTestVisible = true) on the common element surface with XML docs.
  • Added a coverage test and regenerated the API index references (reactor.api.txt copies).

Reviewed changes

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

Show a summary per file
File Description
tests/Reactor.Tests/ElementExtensionsCoverageTests.cs Adds coverage ensuring the new fluent modifier sets ElementModifiers.IsHitTestVisible.
src/Reactor/Elements/ElementExtensions.cs Adds the public .IsHitTestVisible(...) modifier next to related common modifiers.
src/Reactor/Core/Reconciler.cs Applies IsHitTestVisible to the mounted FrameworkElement when explicitly set and changed.
src/Reactor/Core/Element.cs Adds bool? IsHitTestVisible to ElementModifiers, and includes it in ModifiersEqual and Merge.
skills/reactor.api.txt Regenerates the shipped API index to include the new modifier and modifier field.
plugins/reactor/skills/reactor-dsl/references/reactor.api.txt Regenerates the plugin DSL reference API index to include the new modifier and modifier field.

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

Copilot AI review requested due to automatic review settings July 28, 2026 21:40

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 7 out of 7 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

tests/Reactor.AppTests.Host/SelfTest/Fixtures/ModifierEventFixtures.cs:455

  • The selftest only asserts button.IsHitTestVisible is true after modifiers are cleared. That would still pass if the reconciler accidentally sets the property back to true instead of calling ClearValue(UIElement.IsHitTestVisibleProperty), so it doesn’t actually validate the DP-clear semantics (which matter for recycling/default-value behavior). Consider asserting the local value is UnsetValue as well (similar to the content-alignment checks above).
                    Microsoft.UI.Xaml.Automation.AutomationProperties.GetName(button) != "clear-name"
                    && Microsoft.UI.Xaml.Automation.AutomationProperties.GetAutomationId(button) != "clear-id");
                H.Check("ModifierClear_AccessKeyCleared", button.AccessKey == "");
                H.Check("ModifierClear_HitTestVisibleRestored", button.IsHitTestVisible);
                H.Check("ModifierClear_BorderCleared", button.BorderThickness == new Thickness(0));

@azchohfi
Alexandre Zollinger Chohfi (azchohfi) merged commit d08fc78 into microsoft:main Jul 28, 2026
17 checks passed
Alexandre Zollinger Chohfi (azchohfi) added a commit that referenced this pull request Jul 29, 2026
Follow-up to #810, which added the .IsHitTestVisible(bool) common element modifier but only surfaced it in the generated reactor.api.txt indexes.

- Add .IsHitTestVisible(bool) to the Behavior row of the cheat sheet modifier table (template + regenerated docs/guide/cheat-sheet.md via 'mur docs compile --topic cheat-sheet').

- Document it under Pointer events in the input agent skill and its plugin mirror, including how it differs from .IsEnabled(false).

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 81ffbb15-e00a-4053-967d-e931f4178e8e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add declarative IsHitTestVisible(bool) modifier on the common element surface

3 participants