Skip to content

fix: iOS optionDialog cancel option #1383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 4, 2025
Merged

fix: iOS optionDialog cancel option #1383

merged 6 commits into from
May 4, 2025

Conversation

m1ga
Copy link
Contributor

@m1ga m1ga commented Feb 12, 2024

Alloy:

<Alloy>
    <Window>
        <!-- some other modules, actionbar, views and a listview -->

        <OptionDialog id="dialog" title="Delete item?" onClick="onClickDialog">
            <Options>
                <Option>Yes</Option>
                <Option cancel="true">No</Option>
            </Options>
        </OptionDialog>
    </Window>
</Alloy>

generated

var __alloyId22 = [];
__alloyId22.push("Yes");
__alloyId19 = __alloyId22.push("No") - 1;                    // <- error
$.__views["dialog"] = Ti.UI.createOptionDialog({
  options: __alloyId22,
  cancel: __alloyId19,
  id: "dialog",
  title: "Delete item?"
});

with

[ERROR] TiExceptionHandler:
[ERROR] TiExceptionHandler: ReferenceError: __alloyId19 is not defined
[ERROR] TiExceptionHandler:     at new Controller (/alloy/controllers/machine.js:325:6199)
[ERROR] TiExceptionHandler:     at Object.exports.createController (/alloy.js:427:8)
[ERROR] TiExceptionHandler:     at Button.onClickGo (/alloy/controllers/index.js:251:21)
[ERROR] TiExceptionHandler:     at Button.value (ti:/kroll.js:1430:27)
[ERROR] TiExceptionHandler:     at Button.value (ti:/kroll.js:1477:25)

The <OptionDialog> works fine in a blank project 🤷

This PR will add a var infront of __alloyId19:

var __alloyId22 = [];
__alloyId22.push("Yes");
var __alloyId19 = __alloyId22.push("No") - 1;                    // <- fix
$.__views["dialog"] = Ti.UI.createOptionDialog({
  options: __alloyId22,
  cancel: __alloyId19,
  id: "dialog",
  title: "Delete item?"
});

and the projects builds fine

@m1ga m1ga changed the title fix: optionDialog cancel option fix: iOS optionDialog cancel option Apr 21, 2024
@hansemannn
Copy link
Contributor

I am not confident to review this properly, as it's a change directly in the core compiler. Maybe @cb1kenobi or @janvennemann can help here?

Copy link
Contributor

@janvennemann janvennemann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small suggestion to update the else block as well. Then it should be good to go.

@hansemannn hansemannn merged commit 5451ff3 into master May 4, 2025
5 checks passed
@hansemannn hansemannn deleted the optionFix branch May 4, 2025 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants