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

Error when using _isNarrativeOnMobile #278

Closed
swashbuck opened this issue Jun 29, 2023 · 3 comments · Fixed by #279
Closed

Error when using _isNarrativeOnMobile #278

swashbuck opened this issue Jun 29, 2023 · 3 comments · Fixed by #279
Assignees

Comments

@swashbuck
Copy link
Contributor

swashbuck commented Jun 29, 2023

Subject of the issue

When using _isNarrativeOnMobile: true and viewing on mobile, the following error is shown:

Uncaught (in promise) TypeError: parentChildViews is undefined
    replaceWithNarrative hotgraphicView.js:47

Note that this does not happen if first viewing on desktop and then switching to mobile. It only happens if you are viewing mobile when the page first loads.

Your environment

  • Framework 5.31.11
  • Hot Graphic 6.7.5
  • Narrative 7.4.9

Steps to reproduce

  1. Using a desktop browser, adjust screen width to mobile view (719px or narrower, assuming screenSize properties are default)
  2. In a Hot Graphic, enable _isNarrativeOnMobile
  3. Reload the page

Expected behaviour

No console errors

Actual behaviour

Console error!

Screenshots

Screenshot 2023-06-29 at 3 18 03 PM
@swashbuck
Copy link
Contributor Author

swashbuck commented Jul 7, 2023

Hi @oliverfoster . In the Hot Graphic view, I can prevent the error by changing this line:

const parentChildViews = parentView.getChildViews();

To return an empty array:

const parentChildViews = parentView.getChildViews() || [];

However, I noticed that getChildViews() in adaptView.js will return 'undefined' if _childViews is not set.

https://github.com/adaptlearning/adapt-contrib-core/blob/1e73f329c21e6eb906c102db23f600666117cd74/js/views/adaptView.js#L397

if (!this._childViews) return this._childViews;

Should it return an empty array instead?

if (!this._childViews) return [];

Or is there a better way to handle this in general (ex. changing something in adapt-contrib-narrative)?

@kirsty-hames
Copy link
Contributor

I can also replicate this issue testing on Mac Safari, Chrome and FF. Same conditions, open the browser at mobile screen width and increase the browser width above 719px.

In addition to the console error, multiple instances of Hotgraphic are rendered. The first instance of Hotgraphic displays the narrative slides rather than an image with pins.
multiple_instances_error

github-actions bot pushed a commit that referenced this issue Jul 14, 2023
## [6.7.7](v6.7.6...v6.7.7) (2023-07-14)

### Fix

* Fix error when using _isNarrativeOnMobile (fixes #278) ([8897876](8897876)), closes [#278](#278)
@github-actions
Copy link

🎉 This issue has been resolved in version 6.7.7 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

2 participants