From afe4f0f73e5e8835e8c7a0b6c56f02138ca56911 Mon Sep 17 00:00:00 2001 From: Allen Date: Fri, 17 Jun 2022 01:28:49 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=A2=9Eselect=E5=88=86=E7=BB=84?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E6=A1=86=E5=9C=A8=E5=BC=80=E5=90=AF=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E6=97=B6=E6=94=AF=E6=8C=81=E8=BF=87=E6=BB=A4=E6=9C=AA?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E5=88=B0=E5=88=86=E7=BB=84=E5=85=83=E7=B4=A0?= =?UTF-8?q?=E7=9A=84=E5=88=86=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 目前select分组选择框在开启搜索时,如果一个分组下的所有元素全都不匹配搜索关键字,会仍然展示该分组,影响使用体验。该提交解决了此问题。 --- src/modules/form.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/modules/form.js b/src/modules/form.js index ea8ab4b0..72cbaf8d 100644 --- a/src/modules/form.js +++ b/src/modules/form.js @@ -174,6 +174,7 @@ layui.define('layer', function(exports){ ,input = title.find('input') ,dl = reElem.find('dl') ,dds = dl.children('dd') + ,dts = dl.children('dt') // select分组dt元素 ,index = this.selectedIndex //当前选中的索引 ,nearElem; //select 组件当前选中的附近元素,用于辅助快捷键功能 @@ -187,6 +188,7 @@ layui.define('layer', function(exports){ index = select[0].selectedIndex; //获取最新的 selectedIndex reElem.addClass(CLASS+'ed'); dds.removeClass(HIDE); + dts.removeClass(HIDE); nearElem = null; //初始选中样式 @@ -347,6 +349,13 @@ layui.define('layer', function(exports){ if(value === '' || (origin === 'blur') ? value !== text : not) num++; origin === 'keyup' && othis[not ? 'addClass' : 'removeClass'](HIDE); }); + // 处理select分组元素 + origin === 'keyup' && layui.each(dts, function(){ + var othis = $(this) + ,thisDds = othis.nextUntil('dt').filter('dd') // 当前分组下的dd元素 + ,allHide = thisDds.length == thisDds.filter('.' + HIDE).length; // 当前分组下所有dd元素都隐藏了 + othis[allHide ? 'addClass' : 'removeClass'](HIDE); + }); var none = num === dds.length; return callback(none), none; }; From b66e1dfa7aac50628d36b65f3e53ac5bb989de1b Mon Sep 17 00:00:00 2001 From: Allen Date: Fri, 17 Jun 2022 01:45:50 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E6=A1=86=E7=9A=84=E7=A4=BA=E4=BE=8B=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更新搜索选择框的示例文件 --- examples/form.html | 84 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 65 insertions(+), 19 deletions(-) diff --git a/examples/form.html b/examples/form.html index ceed0d90..11a0a736 100644 --- a/examples/form.html +++ b/examples/form.html @@ -126,25 +126,71 @@
- -
- +
+ +
+ +
+
+
+ +
+ +