Skip to content

Commit

Permalink
fix(core): 馃悰 stricter selector for collapsible header
Browse files Browse the repository at this point in the history
  • Loading branch information
alistair3149 committed Sep 10, 2023
1 parent 2f40541 commit a6a9fe2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 53 deletions.
52 changes: 0 additions & 52 deletions includes/Partials/BodyContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,6 @@ private function makeSections( DOMDocument $doc, array $headingWrappers ) {
// Append the last section body.
$container->appendChild( $sectionBody );

// Mark subheadings
$this->markSubHeadings( $this->getSubHeadings( $doc ) );

return $doc;
}

Expand Down Expand Up @@ -248,53 +245,4 @@ private function getTopHeadings( DOMDocument $doc ): array {

return $headings;
}

/**
* Marks the subheadings for the approiate styles by adding
* the <code>section-subheading</code> class to each of them, if it
* hasn't already been added.
*
* @param DOMElement[] $headings Heading elements
*/
protected function markSubHeadings( array $headings ) {
foreach ( $headings as $heading ) {
$class = $heading->getAttribute( 'class' );
if ( strpos( $class, 'section-subheading' ) === false ) {
$heading->setAttribute(
'class',
ltrim( $class . ' section-subheading' )
);
}
}
}

/**
* Gets all subheadings in the document in rank order.
*
* @param DOMDocument $doc
* @return DOMElement[]
*/
private function getSubHeadings( DOMDocument $doc ): array {
$found = false;
$subheadings = [];
foreach ( $this->topHeadingTags as $tagName ) {
$allTags = DOMCompat::querySelectorAll( $doc, $tagName );
$elements = [];
foreach ( $allTags as $el ) {
if ( $el->parentNode->getAttribute( 'class' ) !== 'toctitle' ) {
$elements[] = $el;
}
}

if ( $elements ) {
if ( !$found ) {
$found = true;
} else {
$subheadings = array_merge( $subheadings, $elements );
}
}
}

return $subheadings;
}
}
5 changes: 4 additions & 1 deletion resources/skins.citizen.styles/components/Sections.less
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@

// Fix button alignment
&-heading,
&-subheading {
&-collapsible > h3,
&-collapsible > h4,
&-collapsible > h5,
&-collapsible > h6 {
display: flex;
align-items: center;

Expand Down

0 comments on commit a6a9fe2

Please sign in to comment.