Fix select placeholder falsy comparison and add value attribute#859
Fix select placeholder falsy comparison and add value attribute#859superdav42 merged 1 commit intomainfrom
Conversation
The placeholder <option> used selected(! $field->value) which incorrectly
selected the placeholder when $field->value was a falsy but valid value
like '0'. Replace with two-argument selected('', (string) $field->value)
and add an explicit value="" attribute.
Follow-up to PR #843 — based on CodeRabbit review suggestion.
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 36 minutes and 45 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔨 Build Complete - Ready for Testing!📦 Download Build Artifact (Recommended)Download the zip build, upload to WordPress and test:
🌐 Test in WordPress Playground (Very Experimental)Click the link below to instantly test this PR in your browser - no installation needed! Login credentials: |
|
Performance Test Results Performance test results for 177463b are in 🛎️! Note: the numbers in parentheses show the difference to the previous (baseline) test run. Differences below 2% or 0.5 in absolute values are not shown. URL:
|
SummaryFollow-up to #843 (by @commercial-hippie) — addresses the additional finding from CodeRabbit's review.
Change-<option <?php selected(! $field->value); ?> class="wu-opacity-75">
+<option value="" <?php selected('', (string) $field->value); ?> class="wu-opacity-75">Uses the proper two-argument Merged via PR #859 to main. aidevops.sh v3.8.28 spent 8m on this as a headless bash routine. |
Summary
Follow-up to #843 (by @commercial-hippie) — addresses the additional finding from CodeRabbit's review.
Two issues on the placeholder
<option>infield-select.php:value=""attribute — without it, the form submits the placeholder text as the value instead of an empty stringselected(! $field->value)treats any falsy value ("0",0,null,"") as "no selection", so a legitimate option with value"0"would incorrectly show the placeholder as selectedChange
Uses the proper two-argument
selected()comparison with explicit string cast, so the placeholder is only selected when the field value is genuinely empty.