Choo: Problems with select boxes (dropdowns)

Created on 12 Oct 2016  路  2Comments  路  Source: choojs/choo

Expected behavior

When changing which option is selected in a select, the UI should correctly update.

Actual behavior

When changing which option is selected in a select, the UI seems to reset the selection to the first one.

Steps to reproduce behavior

See reduced testcase here: https://gist.github.com/emanchado/9514b4219841fbfd03c1fed90b8ce99b. Shitty code, but easy to understand :-)

I'm guessing this is a bug in either choo or yo-yo, since morphdom seems to have a specific testcase for this: https://github.com/patrick-steele-idem/morphdom/tree/41d78acb982bb57949a92a1c377389a3d03b5018/test/fixtures/autotest/select-element.

Most helpful comment

hey @emanchado, i recently came across this bug as well. :bug:

it is most likely the same as https://github.com/maxogden/yo-yo/issues/37, where the suggested fix is to "both set a value on the <select> tag and set the selected attribute on the selected <option>", and the reason for the bug "to do with yo-yo copying the value of the existing select element to the new one (yo-yo/index.js#L29)".

hope this helps. :smile_cat:

All 2 comments

hey @emanchado, i recently came across this bug as well. :bug:

it is most likely the same as https://github.com/maxogden/yo-yo/issues/37, where the suggested fix is to "both set a value on the <select> tag and set the selected attribute on the selected <option>", and the reason for the bug "to do with yo-yo copying the value of the existing select element to the new one (yo-yo/index.js#L29)".

hope this helps. :smile_cat:

Thanks a lot, that worked like a charm. Closing...

Was this page helpful?
0 / 5 - 0 ratings