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

UI: Fix text color precedence in Text component #610

Merged

Conversation

ksharma-xyz
Copy link
Owner

@ksharma-xyz ksharma-xyz commented Feb 12, 2025

TL;DR

Fixed text color precedence in Text component to prioritize explicitly provided colors over local text color.

What changed?

Reordered the color selection logic in the Text component to first check for explicitly provided colors before falling back to LocalTextColor. If neither is specified, it defaults to the theme's onSurface color.

How to test?

  1. Create a Text component with an explicit color parameter
  2. Create a Text component within a CompositionLocalProvider setting LocalTextColor
  3. Verify that the explicit color takes precedence over LocalTextColor
  4. Verify that LocalTextColor is used when no explicit color is provided
  5. Verify that theme's onSurface color is used when neither is specified

Why make this change?

The previous implementation incorrectly prioritized LocalTextColor over explicitly provided colors, which could lead to unexpected text styling behavior. This change ensures that developer-specified colors take precedence, following standard composition principles.

@ksharma-xyz ksharma-xyz changed the title Prefer param color and then LocalComposition Color UI: Fix text color precedence in Text component Feb 12, 2025
Copy link
Owner Author

ksharma-xyz commented Feb 12, 2025

Copy link
Owner Author

ksharma-xyz commented Feb 13, 2025

Merge activity

  • Feb 12, 11:31 PM EST: Graphite rebased this pull request as part of a merge.
  • Feb 12, 11:44 PM EST: Graphite rebased this pull request as part of a merge.
  • Feb 13, 12:03 AM EST: A user merged this pull request with Graphite.

@ksharma-xyz ksharma-xyz force-pushed the 02-12-prefer_param_color_and_then_localcomposition_color branch from 82da464 to 4c76cf4 Compare February 13, 2025 04:44
@ksharma-xyz ksharma-xyz merged commit 5018501 into main Feb 13, 2025
2 checks passed
@ksharma-xyz ksharma-xyz deleted the 02-12-prefer_param_color_and_then_localcomposition_color branch February 13, 2025 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant