Repository navigation
fix(statusbar): round alpha before converting it to hex - #2049
Merged
GitToTheHub merged 1 commit intoNov 20, 2026
Merged
Conversation
When cordova-plugin-statusbar is installed, setBackgroundColor builds an #AARRGGBB string for StatusBar.backgroundColorByHexString. The alpha byte was computed as 255 * alpha and passed to toString(16) without rounding, so a fractional alpha like 0.5 produced "#7f.8ff0099", which the plugin fails to parse. Round it first, the same way SystemBarPlugin does on the native path.
Contributor
|
If this is AI generated add a |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2049 +/- ##
=======================================
Coverage 63.20% 63.20%
=======================================
Files 24 24
Lines 4922 4922
=======================================
Hits 3111 3111
Misses 1811 1811 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
dpogue
approved these changes
Nov 19, 2026
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.
Platforms affected
Android
Motivation and Context
Fixes #2048
When
cordova-plugin-statusbaris installed,window.statusbar.setBackgroundColor()forwards an#AARRGGBBstring toStatusBar.backgroundColorByHexString. The alpha byte was255 * alphapassed straight totoString(16), so any fractional alpha produced an invalid color:rgba(255, 0, 153, 0.5)became#7f.8ff0099, which the plugin can't parse, and the previous color stays.Description
Round the alpha byte with
Math.roundbefore converting it to hex, as suggested in the issue. This matches the native path inSystemBarPlugin, which already doesMath.round(255 * alpha).Testing
Added
spec/unit/cordova-js-src/statusbar.spec.js. There were no specs forcordova-js-srcyet, so it loadsstatusbar.jsin avmcontext with stubbedwindow,documentandcordova/exec, and checks the string passed tobackgroundColorByHexStringfor an opaque color,0.5alpha (#80ff0099) and a small alpha that needs zero-padding (0.02->#05ff0099).#7f.8ff0099and#5.199999999999cff0099.npm run lintpasses.npm run unit-tests: the only failures are 5AndroidCommandLineTools/Api listTargetsspecs, which fail the same way onmasterlocally because there's no Android SDK.I didn't test on a device.
Checklist
(platform)if this change only applies to one platform (e.g.(android))