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

[Panel] Blueprint autofocus property not working as expected #3083

Closed
foxacid opened this issue Jan 13, 2021 · 21 comments · Fixed by #3085
Closed

[Panel] Blueprint autofocus property not working as expected #3083

foxacid opened this issue Jan 13, 2021 · 21 comments · Fixed by #3085
Assignees
Labels
type: bug 🐛 Is a bug; fixes a bug
Milestone

Comments

@foxacid
Copy link

foxacid commented Jan 13, 2021

The video shows a structure field containing a date field as first child. When clicking on an existing entry, the date field pops up and can only be closed by confirming the date. Clicking elsewhere on the structure does nothing and clicking outside of the structure closes the parent as well.

Setting autofocus: false on either date field or its parent structure field does not seem to have any effect. Autofocus also occurs when using the arrow buttons to navigate between structure entries.

k3_structure-date-field-autofocus.mov

Simplified Blueprint

label: Events
type: structure
autofocus: false
fields:
  date:
    extends: fields/date
    required: true
    autofocus: false

Expected behavior

I'd expect autofocus: false to prevent focus when:

  1. Opening a structure field
  2. Navigating between structure field entries

Additionally I'd expect the date field to close when clicking anywhere but the date field (just like a HTML select box), but this should probably be a separate issue report...

Workarounds

The only workaround I found was to add a honeypot line field to intercept the focus (a hidden field doesn't work, unfortunately).

Kirby Version

3.5

Desktop

Mac OS 10.14.6, Firefox 84.0.2

@foxacid
Copy link
Author

foxacid commented Jan 13, 2021

A gap field also works as honeypot 😛

@foxacid
Copy link
Author

foxacid commented Jan 13, 2021

See related issue #3084

@afbora
Copy link
Member

afbora commented Jan 13, 2021

@foxacid Actually I think your use is not correct. Instead of autofocus: false, you should add autofocus: true to another field.

  test:
    label: Test
    type: structure
    fields:
      date:
        label: Date
        type: date
      name:
        label: Name
        type: text
        autofocus: true # used here instead on date field
      text:
        label: Text
        type: text

@afbora
Copy link
Member

afbora commented Jan 13, 2021

Also autofocus issue on structure field fixed 3.5.1. You can test here: https://github.com/getkirby/kirby/releases/tag/3.5.1-rc.1

@foxacid
Copy link
Author

foxacid commented Jan 13, 2021

@foxacid Actually I think your use is not correct. Instead of autofocus: false, you should add autofocus: true to another field.

Thanks, but did you test that? It doesn't work for me, unfortunately...

Also no luck with 3.5.1-rc.1

@afbora
Copy link
Member

afbora commented Jan 13, 2021

@foxacid Did you delete the media folder? Yes, i tested and works as expected.

Could you share full blueprint setup if still doesn't working?

@foxacid
Copy link
Author

foxacid commented Jan 13, 2021

@foxacid Did you delete the media folder? Yes, i tested and works as expected.

Weird. I upgraded via composer and just deleted the media folder. No change.

Could you share full blueprint setup if still doesn't working?

Here's my full blueprint snippet with the 'honeypot' commented out and a test field with type: textto test autofocus:

label: Events
type: structure
sortBy: date asc
columns:
  date:
    width: 1/6
  events:
    width: 5/6
fields:
#  autofocusHoneypot:
#    type: gap
  date:
    extends: fields/date
    required: true
  text:
    type: text
    autofocus: true
  events:
    type: structure
    sortBy: date asc
    autofocus: true
    columns:
      start:
        width: 1/4
      end:
        width: 1/4
      title:
        width: 1/2
    fields:
      start:
        label: Start
        type: time
        width: 1/2
      end:
        label: End
        type: time
        width: 1/2
      title:
        type: text
        label: Title
      text:
        extends: fields/writer
        label: Description
      linkLive:
        label: Live-URL
        type: url
        width: 1/2
      linkOnDemand:
        label: On-Demand
        type: pages
        query: site.find('on-demand')
        max: 1
        width: 1/2

@afbora
Copy link
Member

afbora commented Jan 13, 2021

@foxacid Here screencast with your blueprint on 3.5.1-RC1 (Windows 10, Firefox/Chrome)

3083

@foxacid
Copy link
Author

foxacid commented Jan 13, 2021

Ah! I can confirm that it works when the fields are empty. Store some values and try again, please 😉

@afbora
Copy link
Member

afbora commented Jan 13, 2021

Still working for me. You've not selected the text field from columns. So could you be having this problem? Except for the other issue with the date field calendar, all focus works.

columns:
      date:
        width: 1/6
      text:
        width: 1/6
      events:
        width: 4/6

@foxacid
Copy link
Author

foxacid commented Jan 13, 2021

Thanks for hanging in there! Here's my video reply:

k3_autofocus.mov

@afbora afbora added the type: bug 🐛 Is a bug; fixes a bug label Jan 13, 2021
@afbora afbora added this to the 3.5.1 milestone Jan 13, 2021
@afbora
Copy link
Member

afbora commented Jan 13, 2021

@foxacid Thank you for testing it patiently 👍 I can see it now 😅 I hope will be fixed 3.5.1 stable version at next week.

@foxacid
Copy link
Author

foxacid commented Jan 13, 2021

@afbora cool. I still believe that an implementation of autofocus: false would be helpful as not all fields accept the autofocus property. In my use case for example, there's only a date and a structure field and the latter cannot be used to intercept the focus...

@afbora
Copy link
Member

afbora commented Jan 14, 2021

The autofocus value of a field is always false. I've fixed the issue on #3085

@afbora afbora linked a pull request Jan 14, 2021 that will close this issue
4 tasks
@afbora afbora self-assigned this Jan 18, 2021
bastianallgeier added a commit that referenced this issue Jan 19, 2021
…tructure-fields

Fixes autofocus fields in structure fields #3083
@afbora
Copy link
Member

afbora commented Jan 19, 2021

@afbora afbora closed this as completed Jan 19, 2021
@maxchene
Copy link

I'm still having the same behavior on 3.5.6 and have to add a gap field 😢

@afbora
Copy link
Member

afbora commented Aug 13, 2021

@kaliel86 Could you post your structure blueprint to test please?

@maxchene
Copy link

maxchene commented Aug 13, 2021

Of course, here it is.
If i remove gap field, first date field is autofocused when clicking 'Add a session' button.

sessions:
            label: Session(s)
            type: structure
            help: Merci de renseigner 1 session minimum et 3 sessions maximum
            max: 3
            min: 1
            autofocus: false
            sortBy: start asc
            fields:
              gap:
                type: gap
                width: 1/4
              start:
                label: Date de début
                type: date
                display: DD.MM.YYYY
                required: true
                autofocus: false
              end:
                label: Date de fin
                type: date
                display: DD.MM.YYYY
                required: true
              delai_realy_bird:
                label: Délai Early bird
                type: date
                display: DD.MM.YYYY
              delai_inscription:
                label: Délai d'inscription
                type: date
                display: DD.MM.YYYY
                required: true
              lien_inscription:
                label: Lien d'inscription
                type: url
                icon: url
                required: true
              lien_calendrier:
                label: Lien du calendrier
                type: url
                icon: url
                placeholder: https://yolo.com
                required: true

@afbora
Copy link
Member

afbora commented Aug 13, 2021

@kaliel86 I can't reproduce the issue when i click to add button in 3.5.6. If you click to date in row to edit, this is intended behavior.

@maxchene
Copy link

maxchene commented Aug 13, 2021

Did you tried with gap field removed ?

@afbora
Copy link
Member

afbora commented Aug 13, 2021

Yes, you right. My mistake. Could you create new issue for this please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Is a bug; fixes a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants