You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for the report! This is something that I accidentally introduced during the iD v2 refactor, and it's a weird side effect of how JavaScript and D3 works.
You could trigger the bug by switching directly from one preset with a oneway to another preset with a oneway. D3 does not re-enter the field in that situation, and so the existing click handler was getting re-used. Because that click handler uses a closure variable value, that variable would stay around from "the time that the function was first created", i.e. the original oneway field.
The fix is: any handlers that use closure variables need to be assigned on the "update" selection, not the "enter" selection.
bad:
// select the field, join to [0] to create singletonvarfield=selection.selectAll('.foo').data([0]);// create dom elements that don't yet existvarenter=field.enter().append('input').attr('class','foo').on('click',function(){ ... dosomethingwithvalueclosurevariable...});// merge enter selection into update selectionvarinput=input.merge(enter);
good:
// select the field, join to [0] to create singletonvarfield=selection.selectAll('.foo').data([0]);// create dom elements that don't yet existvarenter=field.enter().append('input').attr('class','foo');// merge enter selection into update selectionvarinput=input.merge(enter);// update selection runs every timeinput.on('click',function(){ ... dosomethingwithvalueclosurevariable...});
On highways I'm unable to toggle away from
oneway=no
tooneway=yes
using the checkboxes.Screen recording
macOS 10.12.1
Chrome 55.0.2883.75 (64-bit)
The text was updated successfully, but these errors were encountered: