浏览代码

Fix filter control clearing select values afer search (#6203)

Resolves: https://github.com/wenzhixin/bootstrap-table/issues/6125

- In scenarios where a `select` filter control is used along with server search & pagination, selected values were being cleared on performing search
- This was caused by `cacheValues` failing to cache the the select value, and subsequently the value could not be restored in `setValues`
- This was caused due to the logic for `getElementClass` missing a case for filtering out `form-select`
- The `select` element has the following classes

```html
<select class="form-select bootstrap-table-filter-control-price">
<!-- ... -->
</select>
```

Test Plan:

- Verify this fix against https://live.bootstrap-table.com/code/coshlo/11382
- Select an item from the drop down
- Verify it isn't cleared when the search / filtering completes
Kas 3 年之前
父节点
当前提交
f861c0b7ac
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      src/extensions/filter-control/utils.js

+ 6 - 1
src/extensions/filter-control/utils.js

@@ -112,7 +112,12 @@ export function fixHeaderCSS ({ $tableHeader }) {
 }
 
 export function getElementClass ($element) {
-  return $element.attr('class').replace('form-control', '').replace('focus-temp', '').replace('search-input', '').trim()
+  return $element.attr('class')
+    .replace('form-control', '')
+    .replace('form-select', '')
+    .replace('focus-temp', '')
+    .replace('search-input', '')
+    .trim()
 }
 
 export function getCursorPosition (el) {