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

Always include node in event callbacks

Open danielma opened this issue 7 years ago • 7 comments

This is a big change, but I think it would make development a lot more pleasant.

Similar to working with React in a browser context, there are a lot of reasons that having a reference to a Node is useful.

One of the most basic React DOM cases is text inputs. You create the input, and use event.target.value to set the state of your component.

In react-blessed, having access to nodes in events would be useful, but they're largely not available (except focus and blur events).

Because of this, I end up needing to create refs for almost every element, which isn't necessarily bad, but my preference would be to just have access to the node in event callbacks.

Please let me know what you think of this change!

danielma avatar Dec 20 '17 01:12 danielma

Hello @danielma. Thanks for your PR. I need to check the event emitting code again though. I don't remember what was chosen and how it worked. I guess we should give access to the blessed event data but I don't remember what blessed yield as event.

Yomguithereal avatar Dec 20 '17 07:12 Yomguithereal

As far as I can tell from looking at blessed, this would give us full access to everything from blessed. Every blessed Node extends from EventEmitter, which recommends using this to get access to the emitter instance.

danielma avatar Dec 20 '17 16:12 danielma

So there's no way in blessed to access current node in an event handler without needing to hit this? The payload never provides it?

Yomguithereal avatar Dec 21 '17 09:12 Yomguithereal

@Yomguithereal yep, that's correct as far as I'm aware

danielma avatar Dec 21 '17 17:12 danielma

👍 I'd like to see this happen as well.

geolessel avatar Jul 22 '18 03:07 geolessel

Can someone checks if blessed evolved regarding this matter? I did not track its most recent updates.

Yomguithereal avatar Jul 23 '18 08:07 Yomguithereal

@Yomguithereal blessed hasn't been updated in over 3 years.

geolessel avatar Jul 23 '18 14:07 geolessel