Select multiple with optgroup is **completely broken**

I have posted recently regarding select opgroup problems.

Turns out that select multiple when you use optgroup is completely broken AFAICS, it will not even render a basic template correctly.

No handlers, no code, no can-value or anything it renders a basic select optgroup incorrectly

this is stache templates using can.2.3.23.min.js

template as here —

<select name="{{fieldname}}" {{multiple}}>
  <option value="">-- choose --<option>
{{#each optgroups}}
  <optgroup label="{{label}}">
{{#each options}}
    <option value="{{value}}">{{label}}</option>
{{/each}}
  </optgroup>
{{/each}}
<select>

and can.Map({
  optgroups: [
    {label: ‘group one’,
    options: [
      {value= 1, label: ‘item one’},
      {value= 2, label: ‘item rwo’},
      {value= 3, label: ‘item three’}
  ]},
    {label: ‘group two’,
    options: [
      {value= 4 label: ‘item four’},
      {value= 5, label: ‘item five’},
      {value= 6, label: ‘item six’}
  ]}
})

will render with every option selected instead of nothing selected

AFAICS optgroup in single selects is fine

If I’m correct then this should be fixed as a matter of some urgency, if we cannot reliably render a template from given data then it’s game over.

If I’m wrong them I am more than happy for you to show me how and why

I don’t think I’m being stupid over this but …

Ron Yuen

This issue seems reported here: https://github.com/canjs/canjs/issues/2369. If you are interested, I can pair on this w/ you tomorrow.

Justin

Thanks for the extremely quick response. I’ll take a look at your link.

As for ‘pairing’ I’m happy to do what I can, not too sure what that will be.

I’m a Brit, in France and operating on CET - that’s 1hr ahead of GMT, not sure where you hang out and so what the time difference is.

Let me know when and what I need to do / setup for this session and I’ll endeavour to comply

Regards

Ron

How was it finally fixed?

Created an example https://jsbin.com/medifub/edit?html,js,output

This was fixed in can-util 3.3.6 :tada:

1 Like