-
Notifications
You must be signed in to change notification settings - Fork 49
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
Navigation.showError() modals are unable to be dismissed #52
Comments
@dnicolson Can you give me a working fork somewhere to test this behaviour? Some things to help you further.
const errorTpl = (data) => `
<document>
<descriptiveAlertTemplate>
<title>${data.title}</title>
<description>${data.message}</description>
<button data-alert-dissmiss="true">
<text>Ok</text>
</button>
</descriptiveAlertTemplate>
</document>`;
ATV.start({
menu: {
// menu items
},
templates: {
// global error template
error: errorTpl
});
// somewhere in your app
ATV.Navigation.showError({data: {title: 'Error', message: 'This modal can be dismissed'}}); Let me know if this works 🙌 |
Here is a fork showing the modal: https://github.com/dnicolson/appletv-demo I tried using a global template but the button didn't dismiss the modal either. |
I see a couple of issues with the usages.
Having said that, what is the use case that you are trying to solve? If you are just trying to show an error on some failure during page load, I recommend you use the const HomePage = ATV.Page.create({
name: 'home',
template: template,
ready(options, resolve, reject) {
// some async action for success
// resolve({data})
// some action that results in error
reject({
status: 'CUSTOM_ERROR',
data: {
// custom data
}
})
}
});
const customErrorTpl = (data) => `
<document>
<descriptiveAlertTemplate>
<title>${data.title}</title>
<description>${data.message}</description>
<button data-alert-dissmiss="true">
<text>Ok</text>
</button>
</descriptiveAlertTemplate>
</document>`;
ATV.start({
menu: {
items: [{
// make this static page your homepage that will not generate errors
// the user will be navigated to this page on app load without errors
// as such the navigation stack will not be empty for subsequent
// navigations and any subsequent errors can be dismissed
id: 'search',
name: 'Search',
page: SearchPage,
attributes: {
autoHighlight: true
}
}, {
id: 'homepage',
name: 'Home',
page: HomePage,
}]
},
templates: {
// custom status based error template
status: {
'CUSTOM_ERROR': customErrorTpl
}
},
onLaunch(options) {
// navigate to menu page
ATV.Navigation.navigateToMenuPage();
}
}); Please mention your intended use case that you are trying to solve so that I can help you further. This doesn't seem to be a bug, it's rather a framework usage and understanding issue tbh. |
Thanks for the prompt and detailed follow up.
I'm curious as to why the modal is not dismissed as the I have updated the fork so it calls I suspect it has something to do with the PlayPage being invoked with a |
There are a lot of anomalies and weird behaviours that can cause your app to crash if you use the raw TVMLKit JS. E.g if you try to pop the last element from the default navigation stack, you'd notice an app crash. As such this thin layered atvjs framework exist to let developers focus on app creation without the worry of such anomalies. So the APIs might look similar but under the hood, atvjs takes care of these anomalies by maintaining internal states where needed and extending the default behaviours, provided you use the atvjs' methods instead of the raw TVMLKit JS methods.
I don't really understand what are you trying to do, the code in your fork doesn't really make much sense. Are you familiar with the async and promise concepts and in general the general JS + Web concepts? If not, it'd be great to get a familiarity with the basic concepts before diving straight into the app usage and not try just trial and error. I don't see you followed the sample code that I wrote here, please read through the code to see the proposed changes. The code clearly said to add a status base I'm afraid I'm not able to help you any further until you have tried the steps shown in the code above 🙏 |
Sorry for the confusion, the examples in the fork were contrived and for the sake of brevity only included minimal changes from the original code. I was following the appletv-demo example where a promise is rejected without a status from a page invoked with a I have updated the code which shows that from the |
Modal dialogs created with
navigationDocument.presentModal()
are able to be dismissed but usingNavigation.showError()
results in a dialog where the button does not work, escape or home must be used to dismiss.Consider the following code if added to the Movie Catalog example app in the
ready
method of theHomePage
object:The uncommented version works as expected. Inverting the commented code results in the modal not being dismissed but with the
data-alert-dissmiss
[sic] attribute thenavigationDocument.dismissModal()
method is called, as indicated by the log:close button clicked within the modal, dismissing modal...
The text was updated successfully, but these errors were encountered: