Skip to content

Conversation

@XAML-Knight
Copy link
Contributor

Fixes CommunityToolkit/Windows#107

PR Type

What kind of change does this PR introduce?

  • Bugfix (correct memory leak)

What is the current behavior?

Steps to Reproduce:

  1. Use AncestorType in some XAML content (TokenizingTextBox, for example)
  2. Load the XAML content (eg navigate to it in a frame)
  3. Unload the XAML content (eg navigate away from it, remove it from the visual tree)
  4. Notice that the XAML elements are never freed correctly, keep taking memory, and weak references will still resolve.

What is the new behavior?

The elements should be freed.

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tested code with current supported SDKs
  • Pull Request has been submitted to the documentation repository instructions. Link:
  • Sample in sample app has been added / updated (for bug fixes / features)
  • New major technical changes in the toolkit have or will be added to the Wiki e.g. build changes, source generators, testing infrastructure, sample creation changes, etc...
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Header has been added to all new source files (run build/UpdateHeaders.bat)
  • Contains NO breaking changes

Other information

dpaulino and others added 30 commits March 18, 2021 18:36
This improves the design when some tabs are hidden
This fixes potential issues with shared instances of the brush
michael-hawker and others added 21 commits September 2, 2021 12:24
…-named-generated-property

Fixed [ObservableProperty] for fields named "value"
…lick-fix

Improving ComboBoxColumn behavior to prevent triple click behavior
…zingtextbox-header-fix

Fix TokenizingTextBox header to behave like normal text control headers
…#4206)

<!-- 🚨 Please Do Not skip any instructions and information mentioned below as they are all required and essential to evaluate and test the PR. By fulfilling all the required information you will be able to reduce the volume of questions and most likely help merge the PR faster 🚨 -->

<!-- 👉 It is imperative to resolve ONE ISSUE PER PR and avoid making multiple changes unless the changes interrelate with each other --> 

<!-- 📝 Please always keep the "☑️ Allow edits by maintainers" button checked in the Pull Request Template as it increases collaboration with the Toolkit maintainers by permitting commits to your PR branch (only) created from your fork. This can let us quickly make fixes for minor typos or forgotten StyleCop issues during review without needing to wait on you doing extra work. Let us help you help us! 🎉 -->

### Note: This is a copy of the previously reviewed work with a new branch name
## Fixes CommunityToolkit#2493
<!-- Add the relevant issue number after the "#" mentioned above (for ex: "## Fixes CommunityToolkit#1234") which will automatically close the issue once the PR is merged. -->

<!-- Add a brief overview here of the feature/bug & fix. -->
This prevents DataGrid from assuming focus should be reset back to itself when a control inside DataGridTemplateColumn gains focus. This is my first WCT PR, so please go easy on me 😆 
## PR Type
What kind of change does this PR introduce?
<!-- Please uncomment one or more options below that apply to this PR. -->
Bugfix 
<!-- - -->
<!-- - Feature -->
<!-- - Code style update (formatting) -->
<!-- - Refactoring (no functional changes, no api changes) -->
<!-- - Build or CI related changes -->
<!-- - Documentation content changes -->
<!-- - Sample app changes -->
<!-- - Other... Please describe: -->


## What is the current behavior?
<!-- Please describe the current behavior that you are modifying, or link to a relevant issue. -->
Trying to open a control like CalendarDatePicker from within a DataGridTemplateColumn doesn't work, as there is specific behavior to detect when DataGrid loses focus and return it. This doesn't make much sense for controls which require focus to function properly.

## What is the new behavior?
<!-- Describe how was this issue resolved or changed? -->
When the DataGrid loses focus, we now specifically detect if the editing column is a DataGridTemplateColumn and alter the behavior to accommodate this.

## PR Checklist

Please check if your PR fulfills the following requirements:

- [x] Tested code with current [supported SDKs](../readme.md#supported)
- [ ] Pull Request has been submitted to the documentation repository [instructions](..\contributing.md#docs). Link: <!-- docs PR link -->
- [ ] Sample in sample app has been added / updated (for bug fixes / features)
    - [ ] Icon has been created (if new sample) following the [Thumbnail Style Guide and templates](https://github.com/CommunityToolkit/WindowsCommunityToolkit-design-assets)
- [ ] New major technical changes in the toolkit have or will be added to the [Wiki](https://github.com/CommunityToolkit/WindowsCommunityToolkit/wiki) e.g. build changes, source generators, testing infrastructure, sample creation changes, etc...
- [ ] Tests for the changes have been added (for bug fixes / features) (if applicable)
- [ ] Header has been added to all new source files (run *build/UpdateHeaders.bat*)
- [x] Contains **NO** breaking changes

<!-- If this PR contains a breaking change, please describe the impact and migration path for existing applications below.
     Please note that breaking changes are likely to be rejected within minor release cycles or held until major versions. -->


## Other information
I'm unsure if this is the *best* way to do this, but it makes the most sense given how DataGrid already has the capability to detect the editing element and column type.
Additional context before branch rename: CommunityToolkit#4206
Related: unoplatform/uno#6543
…st-winui-version

UITests: Remove ref to incorrect version of winui
…-toolkit-sg

Fix and enable MVVM Toolkit source generator unit tests
…ment layout changes and visibility changes
…-tools

Convert `DesignTools` projects to Sdk-style
…rp-version-diagnostic

Add C# language version diagnostic

treeRoot.Unloaded += (sender, e) =>
{
Assert.AreEqual(grid, null);
Copy link
Member

Choose a reason for hiding this comment

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

Wonder if this is getting called late and causing a problem as immediately after this the test ends...

We're also waiting for the Unloaded event from the content itself as part of the VisualUITestBase Cleanup method, so we may need to try forcing your content to unload first before letting the test end?

Maybe try calling await SetTestContentAsync(null) after this? The Clean-up method also shows using a TaskCompletionSource too which we could use to await the event to ensure we got the unloaded callback and the assert is checked.

XAML-Knight and others added 5 commits September 9, 2021 10:23
…vents

Fix CommunityToolkit#4214 - Update AttachedDropShadow visual on layout/visibility
…diog/ToCompositionString

Prevent floats from being represented in scientific notation in expression animation strings
@XAML-Knight
Copy link
Contributor Author

This PR closed, and relevant bits moved to #4236

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

Labels

bug 🐛 An unexpected issue that highlights incorrect behavior extensions ⚡ in progress 🚧

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FrameworkElementExtensions.Ancestor causes an XAML memory leak