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

Adapt.scrollTo: assumes the selector parameter will always refer to an 'Adapt Element' #2928

Closed
moloko opened this issue Sep 25, 2020 · 1 comment

Comments

@moloko
Copy link
Contributor

moloko commented Sep 25, 2020

Prior to v5.7.0 you could do something like Adapt.scrollTo('.c-110 .component__feedback') - but the change from #2761 means this no longer works - as it now assumes you're trying to scroll to an 'Adapt element', so does Adapt.findById on it (to check if it has rendered and wait if not) - which fails as "c-110 .component__feedback" is obviously not a valid Adapt ID.

Possible solution: change parameter to selectorOrAdaptId and only perform the 'check if ready' code if the supplied parameter is an Adapt ID?

Side note: should also update the JSDoc comment for this to make it clear that it's a CSS 'class' selector that's required.

@moloko moloko changed the title Adapt.nagivateToElement: assumes the selector parameter will always be an Adapt ID Adapt.nagivateToElement: assumes the selector parameter will always refer to an 'Adapt Element' Sep 25, 2020
@moloko moloko changed the title Adapt.nagivateToElement: assumes the selector parameter will always refer to an 'Adapt Element' Adapt.scrollTo: assumes the selector parameter will always refer to an 'Adapt Element' Sep 25, 2020
@moloko
Copy link
Contributor Author

moloko commented Sep 25, 2020

As a temporary workaround in my project, I changed this:

const currentModelId = selector.replace(/\./g, '');
const currentModel = Adapt.findById(currentModelId);
if (!currentModel) return;
if (!currentModel.get('_isRendered') || !currentModel.get('_isReady')) {
await Adapt.parentView.renderTo(currentModelId);
}

to this:

const currentModelId = selector.replace(/\./g, '');
const currentModel = Adapt.findById(currentModelId);
if (currentModel && (!currentModel.get('_isRendered') || !currentModel.get('_isReady'))) {
  await Adapt.parentView.renderTo(currentModelId);
}

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

No branches or pull requests

1 participant