blessed
blessed copied to clipboard
When adding a callback to screen.on 'resize' the parents of the instances are null
An example:
screen.on('resize', function () {
loggers.forEach(logger => logger.instance.emit('attach'));
// workaround: assign this (screen)
// testerPctComplete is a contrib.donut
testerPctComplete.instance.parent = this;
testerPctComplete.instance.emit('attach');
statTable.instance.emit('attach');
// Next line (newBugs is a contrib.lcd) causes the lcd to completly dissapear
//newBugs.instance.emit('attach');
// totalProgress is a contrib.gauge
// workaround: assign this (screen)
totalProgress.instance.parent = this;
totalProgress.instance.emit('attach');
});
this exhibits itself in blessed/lib/widgets/element at:
https://github.com/chjj/blessed/blob/eab243fc7ad27f1d2932db6134f7382825ee3488/lib/widgets/element.js#L1060
For example, without the contrib.gauge
assignment of screen to it's parent, we get the following:
TypeError: Cannot read property 'width' of null
at Gauge.Element._getWidth (node_modules/blessed/lib/widgets/element.js:1060:20)
at Gauge.width (node_modules/blessed/lib/widgets/element.js:1095:15)
at Gauge.calcSize (node_modules/blessed-contrib/lib/widget/gauge.js:36:36)
at Gauge.
the line src/view/dashboard.js:468:30
is the totalProgress.instance.emit('attach');
line.