fix(ios): Prevent transparent colors from making icons invisible#1193
Open
SebastianThiebaud wants to merge 1 commit intoreact-native-menu:masterfrom
Open
fix(ios): Prevent transparent colors from making icons invisible#1193SebastianThiebaud wants to merge 1 commit intoreact-native-menu:masterfrom
SebastianThiebaud wants to merge 1 commit intoreact-native-menu:masterfrom
Conversation
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.
Overview
Problem
When
imageColorisundefinedin aMenuAction,processColor(undefined)returns a transparent color(0,0,0,0). This transparent color is then applied as a tint to menu icons usingwithTintColor(), making the icons completely invisible.Solution
Check if the color's alpha component is greater than 0 before applying the tint. This prevents transparent colors from being applied, allowing icons to display with their default appearance when
imageColoris not provided.Changes Made
File:
ios/Shared/RCTMenuItem.swiftBefore:
After:
Test Plan
Prerequisites
@react-native-menu/menupackageTest Case 1: Menu Icons Without imageColor (Primary Test)
This is the main bug fix - icons should be visible when imageColor is undefined
Test Code:
Expected Results:
Before Fix:
Test Case 2: Menu Icons With Valid imageColor
Ensure the fix doesn't break existing functionality
Test Code:
Expected Results:
Test Case 3: Menu Icons With Transparent Color
Edge case: explicitly passing transparent color
Test Code:
Expected Results:
Test Case 4: Menu Without Icons
Regression test: ensure menus without icons still work
Test Code:
Expected Results:
Test Case 5: Menu With Subactions
Regression test: ensure subactions work correctly
Test Code:
Expected Results:
Test Case 6: Mixed Menu (Some with imageColor, Some without)
Test Code:
Expected Results: