Skip to content
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

fix(datetimepicker): Android Cannot read property 'addEventListener' of undefined #142

Merged
merged 1 commit into from
Jul 26, 2021

Conversation

msaravitz
Copy link
Contributor

Adds a try catch to addEventListener function to prevent a crash on Android. Referenced in #141

@cla-bot
Copy link

cla-bot bot commented Jun 23, 2021

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign the CLA at https://www.nativescript.org/cla.
CLA has not been signed by users: @msaravitz.
After signing the CLA, you can ask me to recheck this PR by posting @cla-bot check as a comment to the PR.

@msaravitz
Copy link
Contributor Author

@cla-bot check

@cla-bot
Copy link

cla-bot bot commented Jun 23, 2021

The cla-bot has been summoned, and re-checked this pull request!

@cla-bot cla-bot bot added the cla: yes label Jun 23, 2021
@edusperoni
Copy link
Contributor

I feel like this workaround will just not listen to the events on this.dateField and this.timeField which should be initialized in the constructor. Maybe Gridlayout is calling addEventListener in its constructor (which probably shouldn't happen).

A better solution would probably be ditching the try catch and using this.dateField?.addEventListener(eventNames, callback, thisArg);

@NathanWalker
Copy link
Contributor

@msaravitz thank you for this - would you like to try @edusperoni 's suggestion? Perhaps just this:

super.addEventListener(eventNames, callback, thisArg);
this.dateField?.addEventListener(eventNames, callback, thisArg);
this.timeField?.addEventListener(eventNames, callback, thisArg);

Then we can bump out a patch for this.

@NathanWalker NathanWalker changed the title fix(datetimepicker) Andorid Cannot read property 'addEventListener' of undefined fix(datetimepicker): Android Cannot read property 'addEventListener' of undefined Jul 23, 2021
@NathanWalker NathanWalker merged commit 1a43026 into NativeScript:master Jul 26, 2021
@NathanWalker
Copy link
Contributor

Released in 2.1.6 - thanks again for contribution @msaravitz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants