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

Focus remains on button #9

Closed
shikkaba opened this issue Apr 17, 2017 · 8 comments
Closed

Focus remains on button #9

shikkaba opened this issue Apr 17, 2017 · 8 comments
Labels

Comments

@shikkaba
Copy link

Clicking on the button in your demo does indeed bring you back to top visually, but the focus remains on the button. The focus should move to wherever the page visually scrolls to instead of staying with the button clicked.

@hsnaydd
Copy link
Owner

hsnaydd commented Apr 18, 2017

Hi @shikkaba

You can do it by yourself.

const moveTo = new MoveTo();
const trigger = document.getElementsByClassName('js-trigger')[0];

moveTo.registerTrigger(trigger, function(target){
  trigger.blur();
  if (target instanceof HTMLElement) {
     target.focus();
  }
});

Thank you.

@shikkaba
Copy link
Author

Thank you for writing this, but I'm just saying that this would be a good thing to have in the script as well.

@hsnaydd
Copy link
Owner

hsnaydd commented Apr 22, 2017

Hi @shikkaba

Thank you for your sugesstion but, I am not sure this is a task that the plugin should do. I dont want to make this plugin complicated. I want to keep it simple and lightweight.

Thank you.

@hackuun
Copy link

hackuun commented Oct 16, 2017

@hsnaydd by "not making it complicated" you make it even more complicated for others people to use. The code above doesn't work for me.

const moveTo = new MoveTo()
    const triggers = document.getElementsByClassName('js-trigger')
    for (var i = 0; i < triggers.length; i++) {
      moveTo.registerTrigger(triggers[i], function (target) {
        triggers[i].blur()
        if (target instanceof HTMLElement) {
          target.focus()
        }
      })
    }

Uncaught TypeError: Cannot read property 'blur' of undefined

Thank you.

@hackuun
Copy link

hackuun commented Oct 16, 2017

Callback doesn't return an element in the loop. It return undefined or 4 (I got 4 elements). It doesn't return actual element!

@hsnaydd
Copy link
Owner

hsnaydd commented Oct 17, 2017

Hi @iamdubx
Can you show me an example on jsfiddle ?

@hackuun
Copy link

hackuun commented Oct 17, 2017

@hsnaydd sure, here - https://jsfiddle.net/Ltstnk0s/

@hsnaydd
Copy link
Owner

hsnaydd commented Oct 17, 2017

Hi @iamdubx

Check this;
https://jsfiddle.net/Ltstnk0s/1/

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

No branches or pull requests

3 participants