getgrav / grav-plugin-admin

Grav Admin Plugin
http://getgrav.org
MIT License
355 stars 227 forks source link

Pressing 'Enter' within input in modal hides the modal #2300

Open woutgg opened 2 years ago

woutgg commented 2 years ago

I have created a modal to quickly create a news page from the admin dropdown at the top, and in general it works fine, but when the input field (for the page title) has focus and 'Enter' is pressed, the modal is just hidden, like it is cancelled.

I'd expect either nothing to happen, or perhaps to have this function as the submit/next action - although that might also be undesirable.

A quick look through the event handlers in the browser devtools did not yet lead me to the code that's causing this.

This is the modal blueprint (user/blueprints/admin/pages/add_news_item.yaml):

form:
  validation: loose
  fields:
    section:
      type: section
      title: ADMIN_MODAL.ADD_NEWS_ITEM.MODAL_TITLE

    title:
      type: text
      label: ADMIN_MODAL.ADD_NEWS_ITEM.TITLE_LABEL
      validate:
        required: true

    folder:
      type: hidden
      default: '@slugify-title'

    route:
      type: hidden
      default: /nieuws

    name:
      type: hidden
      default: 'news-item'

    visible:
      type: hidden
      default: ''

    blueprint:
      type: blueprint

And it is added via user/config/plugins/admin.yaml like this:

add_modals:
  -
    label: ADMIN_MODAL.ADD_NEWS_ITEM.MODAL_TITLE
    blueprint: admin/pages/add_news_item
    show_in: dropdown