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

autofocus issue #563

Open
dkdrk opened this issue Mar 18, 2017 · 2 comments
Open

autofocus issue #563

dkdrk opened this issue Mar 18, 2017 · 2 comments

Comments

@dkdrk
Copy link

dkdrk commented Mar 18, 2017

Autofocus doesn't seem to work due to liquid-fire. Even after adding the following snippet, I couldn't achieve autofocus.

TextSupport.reopen({
  didInsertElement() {
    this._super(...arguments);
    if (this.get('autofocus')) {
      run.scheduleOnce('afterRender', () => {
        this.$().focus();
      });
    }
  }
}); 
@CmdrChaos
Copy link

I am also seeing this behavior. Autofocus behavior works fine outside of a liquid-outlet, but not within one.

@HerveSeger
Copy link

Hi.

I had the same issue so I have customized the move-over.js and fade.js transitions that I was using by adding the scrolling and animation at the end of the promise. It works fine.

app/transitions/move-over.js

...
return firstStep.then(() => {
		const bigger = biggestSize(this, measure);
		oldParams[property] = `${bigger * direction}px`;
		newParams[property] = ['0px', `${-1 * bigger * direction}px`];

		return Promise.all([
			animate(this.oldElement, oldParams, opts),
			animate(this.newElement, newParams, opts, 'moving-in').then(() => {
				$('html,body').animate({
					scrollTop: 0
				}, 'slow');
				$(this.newElement).find('[autofocus]').focus();
			})
		]);
	});

app/transitions/fade.js

...
return firstStep.then(() => {
	return animate(this.newElement, {
			opacity: [(opts.maxOpacity || 1), 0]
		}, opts, 'fade-in')
			.then(() => {
				$('html,body').animate({
					scrollTop: 0
				}, 'slow');
				$(this.newElement).find('[autofocus]').focus();
			});
	});

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

3 participants