Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-82180

Advanced form fields with hideIf() can result in an empty "Show more" section.

XMLWordPrintable

    • MOODLE_402_STABLE, MOODLE_403_STABLE, MOODLE_404_STABLE, MOODLE_405_STABLE
    • Hide

      The following additional CSS can be added to a theme to hide the "Show more..." link unless there is at least 1 visible advanced field. This works with all major browsers as of December 2023.

      .mform .containsadvancedelements .moreless-actions {
        display: none;
      }
      .mform .containsadvancedelements .moreless-actions:has(+ #form-advanced-div > div:not([hidden])) {
        display: block;
      }

      Show
      The following additional CSS can be added to a theme to hide the "Show more..." link unless there is at least 1 visible advanced field. This works with all major browsers as of December 2023. .mform .containsadvancedelements .moreless-actions {   display: none; } .mform .containsadvancedelements .moreless-actions:has(+ #form-advanced-div > div:not( [hidden] )) {   display: block; }

      If all of the advanced form fields in a fieldset are hidden with a hideIf() condition, then the form will display a "Show more" link which expands to an apparently empty section. This looks broken.

      One such example is the quiz settings form (once MDL-68806 lands):

      • Go to Site Administration > Plugins > Quiz > General Settings
      • Uncheck "Locked" for "Pre-create attempts". Leave "Advanced" checked.
      • Set "Pre-create period" to 1 hour.
      • Save changes
      • Go to a course, turn editing on and add a quiz.
      • Expand the "Timing" fieldset.
      • Click on "Show more..." below the "When time expires" field
        • The link will change to "Show less..." but no fields are revealed.
      • Check "Enable" in the "Open the quiz" field.
      • The "Pre-create attempts" field is now shown.

      Ideally, the "Show more" link would only appear if there is something to show.

      This can be resolved with CSS using the :has() selector (See Workaround), but that causes issues on the current CI infrastructure. Modifying the javascript for the hideIf() condition is another route that would allow this to be resolved with greater compatibility.

            Unassigned Unassigned
            marxjohnson Mark Johnson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.