|
| 1 | +# Material ComboBox placeholder lightweight resources (issue #1739) |
| 2 | + |
| 3 | +Implements https://github.com/unoplatform/Uno.Themes/issues/1739. |
| 4 | + |
| 5 | +## Design |
| 6 | + |
| 7 | +The Material v2 ComboBox floating label (`UpperPlaceholderElement`) hardcoded its `CompositeTransform` |
| 8 | +(`ScaleX`/`ScaleY` 0.7, `TranslateY` -11) and its text style (`MaterialBodyLarge`), so tuning it meant copying the |
| 9 | +template. Five additive lightweight keys now carry those values, with defaults equal to the former literals: |
| 10 | + |
| 11 | +| Key | Type | Default | Used by | |
| 12 | +|---|---|---|---| |
| 13 | +| `ComboBoxUpperPlaceHolderScaleX` | `Double` | 0.7 | `UpperPlaceholderElement` transform | |
| 14 | +| `ComboBoxUpperPlaceHolderScaleY` | `Double` | 0.7 | `UpperPlaceholderElement` transform | |
| 15 | +| `ComboBoxUpperPlaceHolderTranslateY` | `Double` | -11 | `UpperPlaceholderElement` transform | |
| 16 | +| `ComboBoxUpperPlaceHolderMargin` | `Thickness` | 0 | `UpperPlaceholderElement` | |
| 17 | +| `ComboBoxPlaceholderTextStyle` | `Style` | `MaterialBodyLarge` | `PlaceholderElement` and `UpperPlaceholderElement` | |
| 18 | + |
| 19 | +- Declared once at the root of Material v2 `SemanticStyles.xaml` (theme-invariant values, like `SmallThumbOffSize`), so |
| 20 | + they are `SemanticResources` and need no per-theme copies. The style key is a `StaticResource` alias, like the style |
| 21 | + aliases at the top of that file. |
| 22 | +- The template reads them through `{ThemeResource}` so a local override (control/page resources) wins. |
| 23 | +- The transform/margin keys keep the existing `PlaceHolder` casing of `ComboBoxUpperPlaceHolderForeground*`; the style |
| 24 | + key name `ComboBoxPlaceholderTextStyle` was chosen by the requester and covers both placeholders. |
| 25 | +- Material v2 only: Simple's ComboBox has no placeholder, Cupertino has no floating label and no semantic layer, |
| 26 | + Fluent templates are WinUI's and not shipped here, Material v1 drives its label through converters. |
| 27 | +- Not covered: the selected value's 5px offset (`NullToContentTranslateYConverter`) stays a converter literal (see Follow-ups). |
| 28 | + |
| 29 | +## Checklist |
| 30 | + |
| 31 | +- [x] Keys in `Styles/Controls/v2/SemanticStyles.xaml` |
| 32 | +- [x] `ComboBox.xaml` template consumes them |
| 33 | +- [x] C# Markup accessors (`Theme.ComboBox.Resources.Default.UpperPlaceHolder.*`, `PlaceholderTextStyle`) |
| 34 | +- [x] `doc/styles/ComboBox.md` |
| 35 | +- [x] Sample on `ComboBoxSamplePage` (M3) |
| 36 | +- [x] Runtime tests `Given_ComboBox` (Material sample app; the Simple host does not reference Uno.Material) + semantic |
| 37 | + membership in Material `Given_SemanticResources` |
| 38 | +- [x] Red run on the pre-change template, green after |
| 39 | +- [x] Full Material suite green; formatting gates clean |
| 40 | + |
| 41 | +## Known limitation (Uno) |
| 42 | + |
| 43 | +On a runtime theme change, Uno re-resolves the `{ThemeResource}` on the `CompositeTransform` (a non-FrameworkElement) |
| 44 | +from `Application.Resources` only, skipping the element's resource chain. Per-control/page overrides of the three |
| 45 | +transform keys therefore revert to the defaults after a theme switch; App.xaml overrides survive. Margin and the text |
| 46 | +style (FrameworkElement properties) keep local overrides in every scope. A `XamlReader.Load` template does not |
| 47 | +reproduce it, only the compiled library template. Native WinUI not verified. Documented in `doc/styles/ComboBox.md`; |
| 48 | +the tests assert what holds and name the gap. Upstream: https://github.com/unoplatform/uno/issues/24958. |
| 49 | + |
| 50 | +## Follow-ups |
| 51 | + |
| 52 | +- Uno: ThemeResource re-resolution on non-FrameworkElement objects in compiled templates (unoplatform/uno#24958). |
| 53 | + Once fixed, extend `When_ThemeChangesAfterLoad_Then_LocalMarginAndStyleAreKept` to the transform keys and drop the doc note. |
| 54 | +- The selected value's 5px offset (`NullToContentTranslateYConverter`) is still fixed, so a moved/rescaled label cannot |
| 55 | + take the value with it. Likely the next request. |
| 56 | + |
| 57 | +## Review |
| 58 | + |
| 59 | +- Red: `When_LightweightResourcesOverridden` failed 4/4 rows on the pre-change template; default test passed. |
| 60 | +- Green (desktop Skia, Debug): `Given_ComboBox` + `Given_SemanticResources` 22/22; full Material suite 95/95. |
| 61 | +- XamlStyler, `dotnet format whitespace`, cspell and markdownlint clean on the changed files. |
| 62 | +- Seven-agent review panel: no blockers; fixes applied (theme-switch coverage, all 5 keys in the semantic check, sample |
| 63 | + uses the style override, doc wording for Margin / style TargetType / ignored setters, this section). |
0 commit comments