Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combobox disappears when reopened #12845

Closed
headslash opened this issue Jul 10, 2023 · 9 comments · Fixed by #12873
Closed

Combobox disappears when reopened #12845

headslash opened this issue Jul 10, 2023 · 9 comments · Fixed by #12873
Assignees
Labels
difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/needs-information Indicates an issue needs more information in order to work on it. triage/untriaged Indicates an issue requires triaging or verification

Comments

@headslash
Copy link

headslash commented Jul 10, 2023

Current behavior

Opening Combobox with Binding in Itemsource works like it should. Dropdown opens with all options. You select one, it binds back like it should.
You reopen it to select something else and...
The whole view that it is in disappears. There is no way other than resetting the application or reloading it to reset it.

I found it while working on a bigger application that uses smaller generated views that could include comboboxes. in those cases it would delete the childview altogether.

I replicated in a minimalistic/same enviroment in the MainPage.
Both the combobox with or without binding has the same issue.

This is in .net7.

recreating this in .net6 does not give the same issue.

Expected behavior

Using a combobox for a second time works like it should, not removing the view altogether

How to reproduce it (as minimally and precisely as possible)

UnoApp1 - example.zip

Workaround

Instead of using

<ComboBox ItemsSource="{x:Bind Title}"/>

using

<ComboBox Grid.Row="3">  
            <ComboBoxItem>ComboBox Item #1</ComboBoxItem>
            <ComboBoxItem IsSelected="True">ComboBox Item #2</ComboBoxItem>
            <ComboBoxItem>ComboBox Item #3</ComboBoxItem>
</ComboBox>

Does work but bindings are not really an option in my case.

Works on UWP/WinUI

None

Environment

Uno.UI / Uno.UI.WebAssembly / Uno.UI.Skia

NuGet package version(s)

all current updated stable versions
no extra ones

Unoplatform extension 4.9.12.12
using .net7

Affected platforms

WebAssembly, Skia (WPF), Skia (GTK on Linux/macOS/Windows)

IDE

Visual Studio 2022

IDE version

17.6.2

Relevant plugins

none

Anything else we need to know?

No response

@headslash headslash added difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification labels Jul 10, 2023
@jeromelaban
Copy link
Member

Thanks for the report. In the repro sample you're providing, you're using a string as the input, and this is not supported by WinUI.

Is your original issue using the same "string" binding as the item source?

@jeromelaban jeromelaban added the triage/needs-information Indicates an issue needs more information in order to work on it. label Jul 10, 2023
@headslash
Copy link
Author

headslash commented Jul 10, 2023

The string binding was just a simple way to make an example because it has the exact same response as the other inputs.
which are string[] (at the start of the project for simplicity) and later ObservableCollection.
In both cases I have problems with the disappearing Views.

I also tested both Binding and x:Bind but those still gave the issue regarding the disappearing views while still functioning properly.

Would you like me to include an example project with those other inputs?

@headslash
Copy link
Author

I'm an idiot, sorry first time doing a propper issue, This is not professional. My bad.

@headslash headslash reopened this Jul 10, 2023
@jeromelaban
Copy link
Member

jeromelaban commented Jul 11, 2023

No worries about closing the issue :)

Are you able to reproduce the issue with the Uno Playground? Here's an example: https://playgroundcanary.z19.web.core.windows.net/#combobox

@headslash
Copy link
Author

I'm unable to reproduce it uno playground, I tried that yesterday to be sure. I also copied the xaml into VS22 in my uno enviroment (.net7) and it has the same problem. I tried it in the .net6 test project and it works just fine.

@jeromelaban
Copy link
Member

Thanks. To be sure, you're testing in WebAssembly, specifically?

@headslash
Copy link
Author

in both webassembly and skia.wpf.
Both have the issue

@jeromelaban
Copy link
Member

jeromelaban commented Jul 11, 2023

Thanks for the update.

Note for contributors

It seems that for some reason, the contents of the Frame is getting cleared when opening the popup for the second time. This does not repro in the playground (http://playground.platform.uno/#ef1ff7f8). It is not related to x:Bind nor material theming.

@MartinZikmund MartinZikmund self-assigned this Jul 11, 2023
MartinZikmund added a commit that referenced this issue Jul 12, 2023
Previously we were clearing ItemsControl items' DataContext instead of nulling them out. Unsetting the DP value caused inheritance to take over, and that meant the item temporarily gained the DataContext of the ItemsControl - which could have been a UIElement, which then caused it to become the item's Content. This caused very odd issues like #12845.
@jeromelaban
Copy link
Member

@headslash the piece of the code that cause the issue to happen is the DataContext = this line. If you're using x:Bind you should not need this particular statement and it will work around the issue.

mergify bot pushed a commit that referenced this issue Jul 20, 2023
Previously we were clearing ItemsControl items' DataContext instead of nulling them out. Unsetting the DP value caused inheritance to take over, and that meant the item temporarily gained the DataContext of the ItemsControl - which could have been a UIElement, which then caused it to become the item's Content. This caused very odd issues like #12845.

(cherry picked from commit 02b42f4)
mergify bot pushed a commit that referenced this issue Jul 20, 2023
Previously we were clearing ItemsControl items' DataContext instead of nulling them out. Unsetting the DP value caused inheritance to take over, and that meant the item temporarily gained the DataContext of the ItemsControl - which could have been a UIElement, which then caused it to become the item's Content. This caused very odd issues like #12845.

(cherry picked from commit 02b42f4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/needs-information Indicates an issue needs more information in order to work on it. triage/untriaged Indicates an issue requires triaging or verification
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants