react-blessed icon indicating copy to clipboard operation
react-blessed copied to clipboard

`keys` prop does not work on List component

Open lilactown opened this issue 8 years ago • 5 comments

Example:

import React, { Component } from "react";
import blessed from "blessed";
import { render } from "react-blessed";

class App extends Component {
  render() {
    return (
      <list
        keys={true}
        width="100%"
        height="100%"
        top={0}
        left={0}
        fg="green"
        items={["1", "2", "3", "4"]}
      />
    );
  }
}

const screen = blessed.screen({
  autoPadding: true,
  smartCSR: true,
  title: "react-blessed hello world",
});

screen.key(["escape", "q", "C-c"], function(ch, key) {
  return process.exit(0);
});

const component = render(<App />, screen)

And a working vanilla-blessed solution:

const blessed = require("blessed");

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({
  parent: screen,
  keys: true,
  left: 0,
  top: 0,
  width: "100%",
  height: "100%",
  fg: "green",
  items: ["1", "2", "3", "4"],
});

screen.render();

lilactown avatar Dec 14 '17 19:12 lilactown

Hum... I won't have time to investigate this before next week @Lokeh. Don't hesitate to open a PR if you feel like it. Else, you can ping me next week if I forget.

Yomguithereal avatar Dec 14 '17 19:12 Yomguithereal

I'll investigate as much as I can. Where do I find react-fiber-types for flow?

lilactown avatar Dec 14 '17 21:12 lilactown

It looks like an issue with blessed. I filed an issue: https://github.com/chjj/blessed/issues/325

Perhaps we could special-case list when it gets added to the tree to add a parent attribute instead of appending it? 😬

lilactown avatar Dec 14 '17 23:12 lilactown

Or, figure out a way to attach event handlers only to the top-level screen and then somehow differentiate the events, kind of like how react-dom does.

lilactown avatar Dec 14 '17 23:12 lilactown

@Lokeh would you mind elaborate? Thanks in advance

---update--- I mis-read your comment and thought you found a cure!

geyang avatar Jan 19 '18 05:01 geyang