Commit 3556c438 authored by Dianne Tennent's avatar Dianne Tennent Committed by Robert Lyon
Browse files

Bug 1939076 Accordians with fieldset pieforms

Changed from links to buttons to make it
screen reader accessible

Change-Id: Ic2bc933a23d820aa7562dd36fe2df98ceb9f7bcd
(cherry picked from commit de8b13cf)
parent 65669911
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ function pieform_element_fieldset(Pieform $form, $element) {
        $triggerclass = $iscollapsed ? 'collapsed': '';
        $ariaexpanded = $iscollapsed ? 'false' : 'true';

        $legendcontent = '<a href="#' . $openparam . '" data-toggle="collapse" aria-expanded="'.$ariaexpanded.'" aria-controls="' . $openparam . '" class="'.$triggerclass.'">';
        $legendcontent = '<button type="button" data-target="#' . $openparam . '" data-toggle="collapse" aria-expanded="'.$ariaexpanded.'" aria-controls="' . $openparam . '" class="'.$triggerclass.'">';

        if (!empty($element['iconclass'])){
            $legendcontent .= '<span class="icon-fieldset icon icon-'.$element['iconclass'].'" role="presentation" aria-hidden="true"> </span>';
@@ -76,7 +76,7 @@ function pieform_element_fieldset(Pieform $form, $element) {
        $legendcontent .= Pieform::hsc($element['legend']);
        $legendcontent .= '<span class="icon icon-chevron-down collapse-indicator right float-right" role="presentation" aria-hidden="true"> </span> ';

        $legendcontent .= '</a>';
        $legendcontent .= '</button>';
    }


+4 −0
Original line number Diff line number Diff line
@@ -67,8 +67,12 @@ class BehatForms extends BehatBase {
    protected function expand_all_fields() {

        // Using jQuery (work properly and run faster then Mink SeleniumDriver)
        // For expanders that are links - old way
        $jscode = "jQuery(\"fieldset.collapsible legend a.collapsed\").each(function(){jQuery(this).trigger('click');});";
        $this->getSession()->executeScript($jscode);
        // For expanders that are buttons - new way
        $jscode = "jQuery(\"fieldset.collapsible legend button.collapsed\").each(function(){jQuery(this).trigger('click');});";
        $this->getSession()->executeScript($jscode);

    }

+10 −0
Original line number Diff line number Diff line
@@ -1634,6 +1634,11 @@ EOF;
        $exception = new ElementNotFoundException($this->getSession(), 'text', null, 'the collapsed section heading containing the text "' . $text . '"');
        $xpath = "//div[contains(concat(' ', normalize-space(@class), ' '), ' collapsible-group ')]" .
                    "//a[contains(concat(' ', normalize-space(@data-toggle), ' '), ' collapse ')" .
                        " and contains(normalize-space(.), " . $textliteral . ")" .
                        " and contains(concat(' ', normalize-space(@class), ' '), ' collapsed ')]" .
                 " | " .
                 "//div[contains(concat(' ', normalize-space(@class), ' '), ' collapsible-group ')]" .
                    "//button[contains(concat(' ', normalize-space(@data-toggle), ' '), ' collapse ')" .
                        " and contains(normalize-space(.), " . $textliteral . ")" .
                        " and contains(concat(' ', normalize-space(@class), ' '), ' collapsed ')]";
        $section_heading_link = $this->find('xpath', $xpath, $exception);
@@ -1657,6 +1662,11 @@ EOF;
        $exception = new ElementNotFoundException($this->getSession(), 'text', null, 'the uncollapsed section heading containing the text "' . $text . '"');
        $xpath = "//div[contains(concat(' ', normalize-space(@class), ' '), ' collapsible-group ')]" .
                    "//a[contains(concat(' ', normalize-space(@data-toggle), ' '), ' collapse ')" .
                        " and contains(normalize-space(.), " . $textliteral . ")" .
                        " and not(contains(concat(' ', normalize-space(@class), ' '), ' collapsed '))]" .
                 " | " .
                 "//div[contains(concat(' ', normalize-space(@class), ' '), ' collapsible-group ')]" .
                    "//button[contains(concat(' ', normalize-space(@data-toggle), ' '), ' collapse ')" .
                        " and contains(normalize-space(.), " . $textliteral . ")" .
                        " and not(contains(concat(' ', normalize-space(@class), ' '), ' collapsed '))]";
        $section_heading_link = $this->find('xpath', $xpath, $exception);
+1 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ jQuery(function($) {
    function updateFileLegend(e) {
        // Get collapsible element with select-file class and
        // title of the file from filebrowser.js
        var selectfileTitle = $('.select-file legend a'),
        var selectfileTitle = $('.select-file legend button'),
            title = e.originalEvent.data.title;

        // Display the file name
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ Scenario: Testing that views & collections are collated properly
    # Turn on anonymous pages
    Given I log in as "admin" with password "Kupuh1pa!"
    And I go to "admin/site/options.php"
    And I follow "Account settings"
    And I press "Account settings"
    And I set the following fields to these values:
    | Allow anonymous pages | 1 |
    And I press "Update site options"
Loading