Skip to content

Instantly share code, notes, and snippets.

@garrettlancaster
Created June 23, 2021 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garrettlancaster/112bb646beb0d2809709836eb6786859 to your computer and use it in GitHub Desktop.
Save garrettlancaster/112bb646beb0d2809709836eb6786859 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
const machine = Machine({
initial: 'Closed',
states: {
Closed: {
on: {
keydown: {
cond: 'isChar',
target: 'Open',
actions: 'focus'
}
}
},
Open: {
on: {
closed: 'Closed'
}
}
}
}, {
actions: {
focus: (_, {select}) => {
console.log('focus', select)
Select2.focusSearch(select)
}
},
guards: {
isChar: (_, {keydown}) => {
if (!keydown) { return; }
return keydown.key.length === 1;
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment