Giter Club home page Giter Club logo

Comments (8)

distantnative avatar distantnative commented on August 22, 2024 3

I've rephrased the title. The focus helper used for dialogs and drawers to set the focus on open should also consider other fields/inputs than the native elements listed in https://github.com/getkirby/kirby/blob/main/panel/src/helpers/focus.js#L28-L37

Technically, button is listed in this selector list which the tags list includes. However, since there are native inputs from other fields present in the drawer as well, those will receive preference currently.

from kirby.

afbora avatar afbora commented on August 22, 2024 1

I think this is not related autofocus: true. First field should be focused in the form without autofocus but doesn't working for some fields (structure, object, blocks and layout). For ex: if first field is text field, it's working. But if first field is blocks field, it doesn't focus to blocks field.

from kirby.

afbora avatar afbora commented on August 22, 2024

Not sure this is bug or intended but not just for tags field, same for also structure, object, blocks and layout field.

from kirby.

gbdesign2023 avatar gbdesign2023 commented on August 22, 2024

@mrflix You can specify which field should be automatically focused on the field properties:
autofocus: true
https://getkirby.com/docs/reference/panel/fields/text#field-properties
Please note: Only the first field with this name is considered.

from kirby.

mrflix avatar mrflix commented on August 22, 2024

Thanks for the hint, Gerrit. I added autofocus: true to the first field (role) and that made the second field (name) autofocus when adding a new row to the structure O_o

from kirby.

gbdesign2023 avatar gbdesign2023 commented on August 22, 2024

Of course, this is not the purpose of the autofocus option if it does not work. Let's wait and see what the developers have to say.

from kirby.

distantnative avatar distantnative commented on August 22, 2024

I added autofocus: true to the first field (role) and that made the second field (name) autofocus when adding a new row to the structure

I cannot reproduce this.

When I add

credits:
  type: structure
  fields:
    role:
      type: tags
      autofocus: true
    name:
      type: tags
    website:
      type: url

the first field gets focused:
Screenshot 2024-03-23 at 15 51 53

Without setting an explicit autofocus, dialogs and drawers will attempt to focus the first element from this list of selectors:

   	 "[autofocus]",
   	"[data-autofocus]",
   	"input",
   	"textarea",
   	"select",
   	"[contenteditable=true]",
   	"[type=submit]",
   	"button"

Since the tags field/input is rather special, the native input element of the text fields grabs the focus instead.

from kirby.

mrflix avatar mrflix commented on August 22, 2024

I can't replicate the bug either. autofocus: true on role works. Thanks for taking the time to test it @distantnative

Since the tags field/input is rather special, the native input element of the text fields grabs the focus instead.

For me it was a very unintuitive experience that the third field received focus when I added a new line. The fields are sorted in order of importance and I always want to fill in the first field first.

from kirby.

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.