fix(button): apply first-time style patches and clear stale style internals#6119
Open
ndonkoHenri wants to merge 10 commits intomainfrom
Open
fix(button): apply first-time style patches and clear stale style internals#6119ndonkoHenri wants to merge 10 commits intomainfrom
style patches and clear stale style internals#6119ndonkoHenri wants to merge 10 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes button style update issues where first-time style changes (e.g., None -> GREEN) failed to appear in the UI, and stale style data persisted after properties returned to defaults.
Changes:
- Enhanced Dart patch resolution to create missing intermediate maps (like
_internals) when applying ADD operations - Modified Python Button and IconButton controls to clear stale style internals when style properties reset to defaults
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| sdk/python/packages/flet/src/flet/controls/material/button.py | Clears _internals["style"] when style properties return to defaults |
| sdk/python/packages/flet/src/flet/controls/material/icon_button.py | Clears _internals["style"] when style properties return to defaults |
| packages/flet/lib/src/models/control.dart | Adds createMissingMaps parameter to getPatchTarget to materialize missing intermediate maps during ADD operations |
| packages/flet/test/utils/control_test.dart | Adds test case verifying ADD patch creates missing intermediate map |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Deploying flet-docs with
|
| Latest commit: |
99350a8
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://6815e2fb.flet-docs.pages.dev |
| Branch Preview URL: | https://fix-button.flet-docs.pages.dev |
Deploying flet-examples with
|
| Latest commit: |
99350a8
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://5fb1bc7e.flet-examples.pages.dev |
| Branch Preview URL: | https://fix-button.flet-examples.pages.dev |
…in control.dart" This reverts commit 462ea7f.
This reverts commit 4539a21.
This reverts commit c5923ce.
When a dict transitions from empty to non-empty (or vice versa), mark the item as replaced and run dataclass removal/addition handlers instead of performing a dict comparison. This ensures correct patch generation by calling _item_replaced, _dataclass_removed and _dataclass_added with the appropriate path/parent/frozen context.
FeodorFitsner
approved these changes
Feb 4, 2026
Update test_object_diff_frozen.py to reflect new diff behavior: instead of add/remove ops on path ['_internals','style'], the tests now expect a single 'replace' on ['_internals'] with the style wrapped in a dict, and a 'replace' to an empty dict when style is removed. This aligns the tests with the changed diff output for Button internals.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #6118
Description
When a
Buttonstarts withoutbgcolor, the first click (None -> GREEN) could update Python state but not the UI.Also, after changing style props back to defaults, stale style data could remain and keep old visuals.
Root cause
Dart patch apply path
_internals.style._internalsdidn’t exist yet, patch target resolution failed to materialize missing intermediate maps.Python control internals
Button/IconButtonwrote_internals["style"]when style-related props were set,Changes
Dart
getPatchTarget(...)with optionalcreateMissingMaps.createMissingMaps: true, allowing creation of missing intermediate maps (e.g._internals) before inserting new keys.Python
self._internals.pop("style", None)Summary by Sourcery
Ensure button style patches correctly materialize intermediate state and clear stale style metadata.
Bug Fixes:
Tests: