CommunityToolkit / CommunityToolkit/Maui

[BUG] StateContainer - Constraints are not working properly

Open
#1,118 6 comments 0 reactions 0 assignees View on GitHub
area/layouts bug
Dominant language
C#
Stars
2.7k
Forks
500
Avg merge
2d 14h
Merged PRs (30d)
7

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Did you read the "Reporting a bug" section on Contributing file?

- [X] I have read the "Reporting a bug" section on Contributing file: https://github.com/CommunityToolkit/Maui/blob/main/CONTRIBUTING.md#reporting-a-bug

### Current Behavior

I have found multiple bugs but I think they can be caused by the same issue: Layouts ignore set constraints when used inside of state container as a state.

| Layout | Layout not inside of state container (working) | Layout inside of the container (not working) |
| -- | -- | -- |
| Grid + Label | ![image](https://user-images.githubusercontent.com/60035933/228228334-a256c65e-dd35-4da4-984d-62dd2425b93a.png) | ![image](https://user-images.githubusercontent.com/60035933/228228807-45235658-77d2-4c23-881e-e9bb85b00ca3.png) |
| ScrollView | ![image](https://user-images.githubusercontent.com/60035933/228229701-4eb0d744-261a-48ed-8a22-ce874ce774ce.png) | ![image](https://user-images.githubusercontent.com/60035933/228230146-df7efcb4-16e9-4083-9cb8-eb561ff1ea5e.png)
| ItemView | ![image](https://user-images.githubusercontent.com/60035933/228231351-8a7420d0-2248-4332-a036-4cfa9e83cddf.png) | ![image](https://user-images.githubusercontent.com/60035933/228231935-9115158b-7001-4716-9ef9-7a3382f29413.png) |

But if set a specific height to that layout it shows up as:
![image](https://user-images.githubusercontent.com/60035933/228232426-75ba812f-97d6-460a-b518-0374f63a850f.png)

These all seem like they originate from how the bounds of the sub-layouts are calculated if they are calculated at all.

### Expected Behavior

Images with expected behavior are in the previous paragraph.

### Steps To Reproduce

I included an application repository where you can try working and not working layouts.

1. We can just run without doing any edits why launches the app which is using a state container.
2. If we want to see working constraints we can uncomment the Working Constraints region.
3. If we want to see a working Scroll View we can uncomment the Working Scroll View region.
4. If we want to see a working refresh view we can uncomment the Working Refresh View region.

### Link to public reproduction project repository

https://github.com/zZHorizonZz/MAUI-Bug-Report-App

### Environment

```markdown
- .NET MAUI CommunityToolkit: 5.0.0
- OS: Windows 10 Enterprise (OS build 19044.2604)
- .NET MAUI: 7.0
```

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.