Skip to content

fix(jsx/dom): apply select value after children are rendered#4847

Merged
yusukebe merged 3 commits intomainfrom
fix-select-input-jsx-dom
Mar 31, 2026
Merged

fix(jsx/dom): apply select value after children are rendered#4847
yusukebe merged 3 commits intomainfrom
fix-select-input-jsx-dom

Conversation

@usualoma
Copy link
Copy Markdown
Member

fixes #4837

What's included in this fix

Related Preact issues

preactjs/preact#446
preactjs/preact#761

The author should do the following, if applicable

  • Add tests
  • Run tests
  • bun run format:fix && bun run lint:fix to format the code

When options and value were set simultaneously on a select element,
the value was applied before option children existed in the DOM,
causing selectedIndex to fall back to 0.

Defer select value assignment to after children rendering, similar
to Preact's approach. This ensures options exist in the DOM before
value matching, while other props like `multiple` are still applied
before children.
For multiple selects with no matching option, selectedIndex was
incorrectly forced to 0. Only reset selectedIndex for single
selects, preserving the browser's default -1 for unmatched
multiple selects.
Avoid DOM property access in the hot render loop by checking the
JSX node's tag property directly.
@github-actions
Copy link
Copy Markdown

Bundle size check

main (018277e) #4847 (5c3b41b) +/-
Bundle Size (B) 18,489B 18,489B 0B
Bundle Size (KB) 18.06K 18.06K 0K

Compiler Diagnostics (tsc)

main (018277e) #4847 (5c3b41b) +/-
Files 229 229 0
Lines 146,731 146,731 0
Identifiers 124,420 124,420 0
Symbols 150,583 150,583 0
Types 157,112 157,112 0
Instantiations 401,446 401,446 0
Memory used 252,815K 252,743K -72K
I/O read 0.03s 0.02s -0.01s
I/O write 0s 0s 0s
Parse time 0.72s 0.73s 0.01s
Bind time 0.28s 0.29s 0.01s
Check time 1.46s 1.47s 0.01s
Emit time 0.01s 0.01s 0s
Total time 2.47s 2.5s 0.03s

Compiler Diagnostics (typescript-go)

main (018277e) #4847 (5c3b41b) +/-
Files 229 229 0
Lines 150,912 150,912 0
Identifiers 125,098 125,098 0
Symbols 190,886 190,886 0
Types 255,496 255,496 0
Instantiations 608,997 608,997 0
Memory used 162,050K 162,124K 74K
Memory allocs 1,767,620 1,768,117 497
Config time 0.001s 0.001s 0s
BuildInfo read time 0.001s 0.001s 0s
Parse time 0.094s 0.101s 0.007s
Bind time 0s 0s 0s
Check time 0.447s 0.448s 0.001s
Emit time 0.005s 0.004s -0.001s
Changes compute time 0.026s 0.038s 0.012s
Total time 0.611s 0.631s 0.02s

Reported by octocov

@github-actions
Copy link
Copy Markdown

HTTP Performance Benchmark

Framework Runtime Average Ping Query Body
hono (origin/main) bun 37,003.32 51,419.17 32,647.28 26,943.50
hono (current) bun 37,314.44 52,099.33 33,371.38 26,472.60
Change +0.84% +1.32% +2.22% -1.75%

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.85%. Comparing base (e1ae0eb) to head (4fb796e).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4847   +/-   ##
=======================================
  Coverage   92.84%   92.85%           
=======================================
  Files         177      177           
  Lines       11643    11653   +10     
  Branches     3469     3473    +4     
=======================================
+ Hits        10810    10820   +10     
  Misses        832      832           
  Partials        1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@usualoma
Copy link
Copy Markdown
Member Author

Hi @yusukebe,
Would you mind reviewing this?

Copy link
Copy Markdown
Member

@yusukebe yusukebe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@yusukebe
Copy link
Copy Markdown
Member

@usualoma

Nice to solve the difficult problem! Thanks.

@yusukebe yusukebe merged commit 75b4308 into main Mar 31, 2026
20 checks passed
@yusukebe yusukebe deleted the fix-select-input-jsx-dom branch March 31, 2026 00:40
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.

[jsx/dom] Select input value not applied when options and value are set simultaneously

2 participants