Skip to content

Add support for custom togglerClasses in Dropdown widget, and addDropdownClass() method. #289

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

terabytesoftw
Copy link
Member

Q A
Is bugfix? ✔️
New feature?
Breaks BC?

Copy link

codecov bot commented Aug 1, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.65%. Comparing base (ae4ac78) to head (b4375aa).

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #289   +/-   ##
=========================================
  Coverage     99.65%   99.65%           
- Complexity      695      697    +2     
=========================================
  Files            23       23           
  Lines          2927     2933    +6     
=========================================
+ Hits           2917     2923    +6     
  Misses           10       10           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@terabytesoftw terabytesoftw changed the title Add support for custom toggler classes in Dropdown widget. Add support for custom togglerClasses in Dropdown widget. Aug 1, 2025
@terabytesoftw terabytesoftw changed the title Add support for custom togglerClasses in Dropdown widget. Add support for custom togglerClasses in Dropdown widget, and addDropdownClass() method. Aug 1, 2025
@terabytesoftw terabytesoftw linked an issue Aug 1, 2025 that may be closed by this pull request
@Mister-42
Copy link
Contributor

Mister-42 commented Aug 2, 2025

addClass() is unhandled for now.
If I understand it correctly, this should add a class to the main <li> container

@terabytesoftw
Copy link
Member Author

terabytesoftw commented Aug 2, 2025

addClass() is unhandled for now. If I understand it correctly, this should add a class to the main container<li>

addClass() works correctly, it adds the class to the widget container, because it should add the class to <li>.

public function testAddClass(): void

And if you're talking about the dropdown container, add the addDropdownClass method to the main Nav widget that renders the container.

public function testDropdownAddClass(): void

@Mister-42
Copy link
Contributor

Fair, but Dropdown::widget()->addClass() is being ignored.

@terabytesoftw
Copy link
Member Author

Fair, but Dropdown::widget()->addClass() is being ignored.

Correct, this is a nested widget and Dropdown is rendered without a container, the container is rendered in Nav.

@Mister-42
Copy link
Contributor

🤔
addDropdownClass adds a class to all dropdowns. Dropdown::widget()->addClass() would add it to just one.
Both are useful, but functionally different.

@terabytesoftw
Copy link
Member Author

🤔
addDropdownClass adds a class to all dropdowns. Dropdown::widget()->addClass() would add it to just one.
Both are useful, but functionally different.

Open a new issue, include your use case, and I'll try to solve it.

@Mister-42
Copy link
Contributor

To give a functional example, I need to add class dropdown-menu-end to the last dropdown (and only the last) dropdown to prevent it from falling off screen.

<ul class="nav navbar-nav ms-lg-auto">
[..]
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle dropdown-menu-end" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">Button</a>
<ul class="dropdown-menu dropdown-menu-end">
<li>
<a class="dropdown-item" href="#">Profile</a>
</li>
<li>
<hr class="dropdown-divider">
</li>
<li>
<a class="dropdown-item" href="#">Logout</a>
</li>
</ul>
</li>
</ul>

@Mister-42
Copy link
Contributor

Oi, Posting at the same time :)
I'll add a new issue

@terabytesoftw
Copy link
Member Author

Oi, Posting at the same time :) I'll add a new issue

This PR adds the ability to add a class to all addDropdownClass() dropdowns, or to just one specifically by adding it from Dropdown->addClass().

@Mister-42
Copy link
Contributor

Tested, working now as expected.
Thank you very much! Yii is awesome 👍🏻

@terabytesoftw
Copy link
Member Author

Tested, working now as expected. Thank you very much! Yii is awesome 👍🏻

In the issues you find when you open them, add a code example, it's easier to understand, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dropdown: togglerClass gets removed by Nav
2 participants