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

Fix nested accordion open #1863

Merged
merged 9 commits into from
Sep 24, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
cleanup
mvorisek committed Sep 20, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 5a78ed5dce2c107866c0038531e8f5eb60b78997
12 changes: 2 additions & 10 deletions demos/interactive/accordion-nested.php
Original file line number Diff line number Diff line change
@@ -5,25 +5,17 @@
namespace Atk4\Ui\Demos;

use Atk4\Ui\Accordion;
use Atk4\Ui\Button;
use Atk4\Ui\Form;
use Atk4\Ui\Header;
use Atk4\Ui\LoremIpsum;
use Atk4\Ui\Message;
use Atk4\Ui\View;

/** @var \Atk4\Ui\App $app */
require_once __DIR__ . '/../init-app.php';

/*
Button::addTo($app, ['View Form input split in Accordion section', 'class.small right floated basic blue' => true, 'iconRight' => 'right arrow'])
->link(['accordion-in-form']);
View::addTo($app, ['ui' => 'clearing divider']);
*/

Header::addTo($app, ['Nested accordions']);

$addAccordionFunc = function ($view, $maxDepth = 2, $level = 0) use (&$addAccordionFunc) {
$addAccordionFunc = function ($view, $maxDepth, $level = 0) use (&$addAccordionFunc) {
$accordion = Accordion::addTo($view, ['type' => ['styled', 'fluid']]);

// static section
@@ -61,4 +53,4 @@
};

// add accordion structure
$addAccordionFunc($app);
$addAccordionFunc($app, 2);
2 changes: 1 addition & 1 deletion src/Accordion.php
Original file line number Diff line number Diff line change
@@ -167,7 +167,7 @@ protected function renderView(): void
}

// Only set Accordion in Top container. Otherwise Nested accordion won't work.
if (!$this->getClosestOwner($this, AccordionSection::class) && !$this->isDynamicSection()) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ibelar why isDynamicSection was introduced, it is still needed?

if ($this->getClosestOwner($this, AccordionSection::class) === null && !$this->isDynamicSection()) {
$this->js(true)->accordion($this->settings);
}