@csedl/hotwire-svelte-helpers 4.8.0 → 4.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -115,6 +115,20 @@ Event Triggers on the panel element:
|
|
|
115
115
|
|
|
116
116
|
- `before-open`
|
|
117
117
|
|
|
118
|
+
## Testing
|
|
119
|
+
|
|
120
|
+
When adding system tests, it is important not to click the button until the event listener has been added.
|
|
121
|
+
|
|
122
|
+
In this package, the stimulus controllers add the class `stimulus-connected` to the button elements after the connect method of stimulus has passed.
|
|
123
|
+
|
|
124
|
+
For example, to test a dropdown button using Playwright, you can do the following:
|
|
125
|
+
|
|
126
|
+
```ruby
|
|
127
|
+
page.wait_for_selector(".dropdown-button.stimulus-connected").click
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
This aligns with the `.hydrated` class of the `svelte-on-rails` gem.
|
|
131
|
+
|
|
118
132
|
## Helpers
|
|
119
133
|
|
|
120
134
|
If the panels are rendered to a different location than the button (see z-index on [rails-app](https://gitlab.com/sedl/stimulusfloatingdropdown)), within a scrollable (e.g.) container, the button would scroll away from the panel. For such cases, add this both data-attributes to the scrollable element:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@csedl/hotwire-svelte-helpers",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.9.0",
|
|
4
4
|
"description": "Hotwire + Svelte helpers for Rails: Stimulus floating dropdowns/toolips + Svelte global panels/modals + RTurbo-friendly utilities. Build together with the rubygem svelte-on-rails and its npm-package.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -18,6 +18,8 @@ export default class extends Controller {
|
|
|
18
18
|
this.element.addEventListener('mouseenter', (e) => this.start_opening(e, panel_id, delay_sec * 1000))
|
|
19
19
|
this.element.addEventListener('mouseleave', (e) => this.close(e, panel_id))
|
|
20
20
|
this.element.addEventListener('click', (e) => this.toggleByClick(e, panel_id))
|
|
21
|
+
|
|
22
|
+
this.element.classList.add('stimulus-connected')
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
start_opening(e, panel_id, delay_ms) {
|