[ALOY-1748] Widget - Regression - weird behavior - some exporting functions are not working with CLI 8.1.1
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Open |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | n/a |
Labels | 9.3.0.GA, Android, CLI8.1.1, Widget, exports, iOS |
Reporter | Francisco Antonio Duran Ramirez |
Assignee | Abir Mukherjee |
Created | 2020-12-17T21:05:42.000+0000 |
Updated | 2021-06-16T15:07:46.000+0000 |
Description
Hello. Good afternoon.
Basically adding a *widget* to any section, and trying to execute a *functionality* which it was *exported* from the section where it was added the widget; some of the exported functionalities are *not working* with the *CLI 8.1.1*, but if you try to use a lower version it is working pretty good, so that's mean that it is a regression. More details, please try to use the project attached.
* XML
<Alloy>
<Widget src="KlassWindow" id="win" />
</Alloy>
* JS
$.win.open();
$.win.showAlert();
This part about $.win.showAlert(); it is working with CLI 8.0.0, but not with CLI 8.1.1.
* WIDGET XML
<Alloy>
<Window class="container" id="win" />
</Alloy>
* WIDGET JS
var args = arguments[0] || {};
exports.open = function () {
$.win.open();
};
exports.showAlert = function() {
alert("CLI 8.0.0 WORKING!!!");
};
Please let me know whether you have any doubt or question.
Thanks, and best,
Antonio Duran.
Attachments
File | Date | Size |
---|---|---|
8.0.0-Working.png | 2020-12-17T21:05:30.000+0000 | 427106 |
8.1.1-NotWorking.png | 2020-12-17T21:05:30.000+0000 | 613677 |
eightononenotworkingcliwidget.zip | 2020-12-17T20:59:50.000+0000 | 8679352 |
Exact same issue here - big issues caused due to this bug, seemingly no way to work around it
Bug also exists in CLI 9.0.1
A workaround (posted in the TiSlack channel) that seems to work is to change your widget slightly to export the function as: $.widget.showAlert = function() { } instead of exports.showAlert... where 'widget' is the top-level View or Window of your widget
This is caused by a behaviour change we overlooked when implementing the linked ticket, if a widget is the only node in a view it will become the top level node. So $.win then becomes a reference to the window in the Widget rather than the Widget itself. Another way to workaround this is to add an empty tag of some kind to the view, so that the Widget tag isn't the only tag in the view. Off the top of my head, I'm not sure how we can maintain the correct behaviour and support ALOY-1256