Code Monkey home page Code Monkey logo

Comments (4)

LFDanLu avatar LFDanLu commented on September 23, 2024 1

Maybe we could modify

if (state.isOpen && e.key === 'Enter') {
e.preventDefault();
}
so that it also skips the preventDefault if the user is in an allowsCustomValue combobox and none of the keys are focused?

from react-spectrum.

sookmax avatar sookmax commented on September 23, 2024

Correct me if I'm wrong, but this issue is only a problem when both allowsCustomValue and allowsEmptyCollection are specified, right? I've noticed that if only allowsCustomValue is set, then the combobox would close automatically when the typed input doesn't match any of the items, and thus the form is submitted via a single enter keystroke.

So I'm not entirely sure if it's a good idea to add an additional logic in the above if-statement to handle this specific use case? since it makes sense to close the menu first (even if it's an empty one), and then submit the form?

Would there be a better way to deal with this?

from react-spectrum.

LFDanLu avatar LFDanLu commented on September 23, 2024

There could also be the case where the user's custom value is a substring of the combobox's dropdown values in which case the dropdown would be open still even if allowsEmptyCollection is false. Open to alternative ideas/opinions but it feels to me that as long as virtual focus isn't set within the dropdown then we can treat interactions as happening purely on the input element and thus we no longer need to prevent default.

from react-spectrum.

ashleyryan avatar ashleyryan commented on September 23, 2024

For now, I've added a workaround that adds a keypress event listener to the input and manually triggers a click on a submit button we have in our component if there's no focusedKey

from react-spectrum.

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.