GithubHelp home page GithubHelp logo

Comments (5)

Akryum avatar Akryum commented on June 9, 2024

What would be the use case for an additional parameter to hide? Doesn't it work if you just listen to hide and focus your button?

from floating-vue.

dobromir-hristov avatar dobromir-hristov commented on June 9, 2024

That will focus if you click outside, or hide via some other mechanism, which is probably not correct 🤔 not exactly sure what is more correct, from an accessibility standpoint.

from floating-vue.

Akryum avatar Akryum commented on June 9, 2024

Maybe you can do something similar to:

function onHide () {
  // Nothing is currently focused
  if (document.activeElement === document.body) {
    myButton.value.focus()
  }
}

from floating-vue.

dobromir-hristov avatar dobromir-hristov commented on June 9, 2024

I'll see if always focusing on hide is a terrible idea. Will give feedback later.

from floating-vue.

dobromir-hristov avatar dobromir-hristov commented on June 9, 2024

Right, that did the trick :)

  const el = document.activeElement
  const popperClass = 'v-popper__popper';
// if no active element, or its the body, or its the popper itself OR is still inside the popper
  if (!el || el === document.body || el.classList.contains(popperClass) || el.closest(`.${popperClass}`)) {
    // focus the trigger button
  }

from floating-vue.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.