Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional `if` does not work as expected with select tag and dynamic options #2229

Closed
Infeligo opened this issue Jan 20, 2017 · 2 comments
Closed
Labels

Comments

@Infeligo
Copy link

@Infeligo Infeligo commented Jan 20, 2017

Help us to manage our issues by answering the following:

  1. Describe your issue:

I wanted to used if attribute on select tag with dynamic options like this:

  <select if={ showSelect }>
    <option each={ list } value={ value }>{ text }</option>
  </select>

However, when if expression value toggles, unexpected artifacts in form of empty selects are left in the DOM.

  1. Can you reproduce the issue?

http://plnkr.co/edit/yPRenJjTIthlG3CPEoPz?p=preview
(click "Toggle" button multiple times to reproduce this issue)

  1. On which browser/OS does the issue appear?

Chrome 55 and Firefox 49 on Windows 8.1

  1. Which version of Riot does it affect?

At least Riot 3.0.7

  1. How would you tag this issue?
  • Question
  • Bug
  • Discussion
  • Feature request
  • Tip
  • Enhancement
  • Performance
@rbatistajs
Copy link

@rbatistajs rbatistajs commented Jan 20, 2017

I made a test by removing the "else" from that line
https://github.com/riot/riot/blob/master/lib/browser/tag/if.js#L37

Getting +/- like this

if (this.current._tag)
    this.current._tag.unmount()

if (this.current.parentNode)
    this.current.parentNode.removeChild(this.current)

I did the test and it worked, just don't know if it's the correct solution.

(Sorry for my bad english)

@GianlucaGuarini
Copy link
Member

@GianlucaGuarini GianlucaGuarini commented Jan 21, 2017

thank you @rbatistajs I will work on a patch soon

GianlucaGuarini added a commit that referenced this issue Jan 28, 2017
GianlucaGuarini added a commit that referenced this issue Jan 28, 2017
* bug/2229:
  closes #2229
  added: test for #2229
@fabien fabien mentioned this issue Feb 5, 2017
1 of 7 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.