Skip to content

Commit 5d853ef

Browse files
committed
fix: #2767 Search field loses focus after search
Signed-off-by: Kostiantyn Miakshyn <molodchick@gmail.com>
1 parent 6be7bdc commit 5d853ef

2 files changed

Lines changed: 248 additions & 223 deletions

File tree

src/utils/debounce.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
4+
*/
5+
6+
import Vue from 'vue'
7+
import { INPUT_DEBOUNCE_MS } from '../models/Constants.ts'
8+
import debounce from 'debounce'
9+
10+
/**
11+
*
12+
* @param {any} initialValue Initial value
13+
* @param {number} delay delay in milliseconds
14+
*/
15+
export function debouncedProperty(initialValue, delay = INPUT_DEBOUNCE_MS) {
16+
const observable = Vue.observable({ value: initialValue })
17+
18+
return {
19+
get() {
20+
return observable.value
21+
},
22+
set: debounce((newValue) => {
23+
observable.value = newValue
24+
}, delay),
25+
}
26+
}

0 commit comments

Comments
 (0)