Events do not work on list appended to a screen
When appending a list to a screen, keyboard events do not work at all.
Example:
const blessed = require("blessed");
// Creating our screen
const screen = blessed.screen({
autoPadding: true,
smartCSR: true,
title: "react-blessed hello world",
});
// Adding a way to quit the program
screen.key(["escape", "q", "C-c"], function(ch, key) {
return process.exit(0);
});
const list = blessed.list({
keys: true,
left: 0,
top: 0,
width: "100%",
height: "100%",
fg: "green",
items: ["1", "2", "3", "4"],
});
screen.append(list);
screen.render();
Changing the creation of the list to include parent: screen and removing the screen.append(list) fixes this.
We need this over at react-blessed because we use append to properly layout the component tree.
I'm not sure if it's the same issue, but I get a "TypeError: Cannot read property 'parent' of undefined" error if I use the append method. The issue for me with the parent parameter is that it automatically is rendered on the screen.
I investigated a bit on this, and it seems that calling list.focus() after the append fixes the issue.
I have no idea how to force this behavior in react-blessed though.
So this sort of makes sense - the list isn't automatically focused as it is attached (because... why would it be). That said - might make sense to do so if nothing was focused and there were no other children.
What would be the expected behavior if you added multiple Lists? The last one be focused? None of them?