CommunityToolkit / CommunityToolkit/Maui

[BUG] MaskedBehaviour does not draw trailing format characters

Open
#2,475 0 comments 0 reactions 0 assignees View on GitHub
bug unverified
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

MaskedBehavior removes all masked characters that exceed the length of the masked input string.
This means the mask `E 000° 00' 00"` with unmasked character `0` and the value `180 00 00` will be rendered as `E 180° 00' 00` without the last quote character.

### Expected Behavior

The trailing format characters should be drawn in the entry.

### Steps To Reproduce

1. Open and run solution from linked reproducible repository.
2. Enter 1200000 without spaces

Further: try adding the last quote character after 1200000

### Link to public reproduction project repository

https://github.com/gabrieltigerstrom/MCT-masked-behavior-reproducible

### Environment

```markdown
- .NET MAUI CommunityToolkit: 11.0.0
- OS: Microsoft Windows 10 Home (10.0.19045 Build 19045)
- .NET MAUI: 9.0.30
```

### Anything else?

Without having done any debugging I feel like the condition on [line 180 in MaskedBehavior.shared.cs](https://github.com/CommunityToolkit/Maui/blob/fbfd456d4ce00bba77a7ec47539dfa39fb6dc682/src/CommunityToolkit.Maui/Behaviors/MaskedBehavior.shared.cs#L180) is suspicious.
My understanding from reading the code is that the formatting will be applied until maximum text length is reached.

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.