Why is the input element not behaving properly in a modal? #322
-
|
I’m working on a new package, starting from the Package Generator. In the view, I have built a simple form which includes an constructor(serializedState) {
this.element = document.createElement('div');
this.element.classList.add('pulsar-tbar');
let form = document.createElement('form');
form.innerHTML = `
<input name="filter" type="text"/>
<ul id="commands"></ul>
<button name="cancel">Cancel</button>
<button name="ok">Add</button>
`;
let filter = form.querySelector('input[name="filter"]');
filter.addEventListener('keyup', event => {
console.log(event.key)
});
this.element.appendChild(form);
}When I toggle the view the form appears, I can type in some content in the input, and the key code is output correctly in the console. However, I can’t backspace, use the arrow keys, or do anything I can normally do with an input. I can select the whole text with the mouse and overtype, but that’s all. Obviously something is hijacking the input. I have tried adding the input without the form, without the event listener, and using Is there a fix for this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
|
In general, ordinary keyboard behavior can be restored by adding the I don't know why the Atom folks originally did it this way (making browser behavior opt-out rather than opt-in), but that's the status quo. Eventually I'd like to make this easier or at least make it more obvious what you need to do in situations like these. |
Beta Was this translation helpful? Give feedback.
In general, ordinary keyboard behavior can be restored by adding the
native-key-bindingsclass name to a parent element.I don't know why the Atom folks originally did it this way (making browser behavior opt-out rather than opt-in), but that's the status quo. Eventually I'd like to make this easier or at least make it more obvious what you need to do in situations like these.