Shopware 6的过滤器侧边栏中停止propapation不允许嵌套折叠
Shopware 6侧栏具有用于过滤器的bootstrap可折叠物品。由于我们为一个属性提供了很多过滤选项,因此我们将其放置在属性 /子特质结构中,并希望折叠子项目。
因此,我们添加
<span class="collapsed" aria-expanded="false" data-toggle="collapse" data-target="#element-2647292d65d44853b2b3faaaf5a9572e">
<span class="icon icon-arrow-medium-down icon-xs">
<svg> [ chevron icon ] </svg>
</span>
</span>
并将subitems放置在DIV中:
<div class="subelement-group collapse" id="element-2647292d65d44853b2b3faaaf5a9572e">
它不起作用,在调试我们发现跨度附带的其他事件侦听器之后,应该扩展subitems div。
随附的事件
dropdownMenu.addEventListener('click', (event) => {
event.stopPropagation();
});
现在,我们想知道我们是否只是向删除此行的Shopware Core提出拉动请求,或者是添加它的原因。
我们还认为,没有其他方法可以消除停止繁殖吗?
edit
我们意识到我们不能仅删除停止范围。如果过滤器是页面顶部的下拉菜单,则需要。 我们还尝试将&lt; span&gt;
转换为&lt; button&gt;
,但似乎仍然没有接收单击事件。
Edit2:类似的东西适合侧边栏: (将跨度更改为按钮后)
dropdownMenu.addEventListener('click', (event) => {
if (event.target.tagName === 'BUTTON' || event.target.closest('button') != null) {
return;
}
event.stopPropagation();
});
对于顶杆,它确实可以很好地工作:扩展时下拉次数仍关闭。
The Shopware 6 sidebar has bootstrap collapsible items for the filters. As we have a lot of filter options for one property, we put them in a properties / sub-property structure and want to collapse the child items.
So we added
<span class="collapsed" aria-expanded="false" data-toggle="collapse" data-target="#element-2647292d65d44853b2b3faaaf5a9572e">
<span class="icon icon-arrow-medium-down icon-xs">
<svg> [ chevron icon ] </svg>
</span>
</span>
And have put the subitems in a div:
<div class="subelement-group collapse" id="element-2647292d65d44853b2b3faaaf5a9572e">
It is not working, and after some debugging we found, that there is an additional event listener attached to the span which should expand the subitems div.
The attached event is this:
dropdownMenu.addEventListener('click', (event) => {
event.stopPropagation();
});
If we remove the stopProgation
call, everything seems to work fine.
Now we a wondering if we just just make a pull request for the Shopware core which removes this line or what could be the reason why it was added.
We also believe that there is no other way to undo the stop propagation?
EDIT
We realized that we cannot just remove the stopPropagation. It is needed in case the filter is a dropdown at the top of the page.
We also tried to convert the <span>
into a <button>
but it still does not seem to receive the click events.
EDIT2: Something like this works for the sidebar:
(after changing the span to a button)
dropdownMenu.addEventListener('click', (event) => {
if (event.target.tagName === 'BUTTON' || event.target.closest('button') != null) {
return;
}
event.stopPropagation();
});
For the top-bar it does ot work so well: The dropdown still closes when expanding.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想最简单的解决方案是禁用
filterbaseplugin._preventdropdownclose
通过我们主题中的JavaScript覆盖,因为我们不使用顶级键。更通用的人会很好,所以我开放以寻求其他答案。
I guess the easiest solution is to disable
FilterBasePlugin._preventDropdownClose
by a JavaScript overwrite in our theme, as we do not use the top-bar.A more generic would be nice, so I am open for additional answers.