Skip to content

Commit a7c9698

Browse files
a.laurowskiAleksander Laurowski
authored andcommitted
FFWEB-2196 collapse current asn group if user clicks outside it or on another group
1 parent 87b022e commit a7c9698

4 files changed

Lines changed: 46 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Changelog
2-
## UNRELEASED
2+
## [Unreleased]
33
### Add
44
- Export
55
- Added new field provider `Omikron\FactFinder\Shopware6\Export\Field\Layout` applicable to CMS Export
@@ -9,6 +9,10 @@
99
- hide `<ff-asn-group>` responsible for rendering category filters as this breaks the Web Components navigation mode.
1010
User should navigate between categories using shop main navigation
1111

12+
### Fix
13+
- Category, SearchResult
14+
- fix `ff-asn-group` does not collapse if user clicks outside it or on another `ff-asn-group`
15+
1216
## [v3.0.1] - 2022.03.10
1317
### Fix
1418
- `Omikron\FactFinder\Shopware6\Subscriber\CategoryView`

src/Resources/app/storefront/dist/storefront/js/omikron-fact-finder.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import TrackingPlugin from './plugin/tracking.plugin';
2+
import AsnPlugin from './plugin/asn-plugin';
23

34
const PluginManager = window.PluginManager;
4-
PluginManager.register('TrackingPlugin', TrackingPlugin)
5+
PluginManager.register('TrackingPlugin', TrackingPlugin);
6+
PluginManager.register('AsnPlugin', AsnPlugin);
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import Plugin from 'src/plugin-system/plugin.class';
2+
3+
export default class AsnPlugin extends Plugin
4+
{
5+
init() {
6+
this.registerEvents();
7+
}
8+
9+
registerEvents() {
10+
document.addEventListener('click', this._handleToggleFilter.bind(this));
11+
}
12+
13+
_handleToggleFilter(event) {
14+
const getAllGroupsExceptClicked = e => {
15+
const clickedGroup = e.target.closest('ff-asn-group');
16+
17+
return [...document.querySelectorAll('ff-asn-group')].filter(g => g !== clickedGroup)
18+
}
19+
20+
const isAsnGroup = e => {
21+
return e.path.find(p => p.tagName === 'ff-asn-group'.toUpperCase());
22+
}
23+
24+
if (!isAsnGroup(event)) {
25+
document.querySelectorAll('ff-asn-group').forEach(g => {
26+
if (g.opened) g.toggle(true);
27+
})
28+
}
29+
30+
if (isAsnGroup(event)) {
31+
getAllGroupsExceptClicked(event).forEach(g => {
32+
if (g.opened) g.toggle(true);
33+
})
34+
}
35+
}
36+
}
37+

0 commit comments

Comments
 (0)