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

Improve dropdown developer experience #206

Merged
merged 9 commits into from
Mar 14, 2024

Conversation

adrienpoly
Copy link
Contributor

Relates to #205

This PR provides several DX improvements for the dropdown component

1. actions are self defined

The action to open close the dropdown and to navigate with the arrow in the menu are self defined by the controller so the html markup becomes simpler. We only need to add the data-controller="dropdown" and the button, menu and menuItem targets

2. closeOnClickOuside option

The current dropdown would always close on a click outside. This is now configurable by setting the data-dropdown-close-on_click-outside-value="true/false". The default is the current behavior (true)

3. closeOnEsc option

The current dropdown would not close on ESC keydown. This is now configurable by setting the data-dropdown-close-on-esc-value="true/false". The default is (true)

4. defines default transition

If unset the dropdown will default to those transitions

enter="transition ease-out duration-200"
enter-from="opacity-0 translate-y-1"
enter-to="opacity-100 translate-y-0"
leave="transition ease-in duration-150"
leave-from="opacity-100 translate-y-0"
leave-to="opacity-0 translate-y-1"

Transition can be set using the Stimulus Class API

<div data-controller="dropdown" data-dropdown-enter-class="transition ease-out duration-1000">

Testing

I wanted to add tests to cover the various logic here but I am struggling to make the test run locally

I cannot run the all suite without getting such errors

CleanShot 2023-10-25 at 22 11 23@2x

src/dropdown.js Outdated Show resolved Hide resolved
@adrienpoly
Copy link
Contributor Author

@marcoroth as you worked on the test suite maybe you have some insights on the test failure part I am experiencing locally.

if I add Playright to the web-runner config and use it to run my tests it works perfectly all tests are green. I added all 3 Chrominium, Firefox and Webkit

With the standard runner, I have the errors mentioned above.

Works perfectly on the CI.....

@excid3 excid3 merged commit 8da97e2 into excid3:main Mar 14, 2024
1 check failed
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.

2 participants