Shopware 6的过滤器侧边栏中停止propapation不允许嵌套折叠

发布于 2025-02-04 21:01:00 字数 1273 浏览 4 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

听闻余生 2025-02-11 21:01:00

我想最简单的解决方案是禁用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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文