3
3
<label :class =" { lifted: !isEmpty }" >{{ props.label }}</label >
4
4
<input
5
5
@focus =" isFocus = true"
6
- @blur ="
7
- isFocus = false;
8
- refreshInput();
9
- "
6
+ @blur =" isFocus = false"
10
7
type =" text"
11
8
v-model =" value"
12
9
ref =" inputRef"
15
12
</template >
16
13
17
14
<script setup lang="ts">
18
- import { computed , ref } from " vue" ;
15
+ import { computed , ref , watch } from " vue" ;
19
16
20
17
const value = defineModel <string >({ required: true });
21
18
const props = defineProps <{
@@ -29,9 +26,12 @@ function refreshInput() {
29
26
// On Chromium browsers, ligatures over 3 characters are not displayed until force refresh
30
27
// Manually setting the value won't trigger Vue's reactivity system, no performance issue
31
28
if (! inputRef .value ) return ;
29
+ const { selectionStart, selectionEnd } = inputRef .value ;
32
30
inputRef .value .value = value .value + " \u200B " ;
33
31
inputRef .value .value = value .value ;
32
+ inputRef .value .setSelectionRange (selectionStart , selectionEnd );
34
33
}
34
+ watch (value , refreshInput );
35
35
</script >
36
36
37
37
<style lang="scss">
@@ -45,6 +45,7 @@ function refreshInput() {
45
45
border-bottom-color 0.2s ;
46
46
padding : 0 ;
47
47
display : flex ;
48
+ font-family : var (--font-math );
48
49
& .focus {
49
50
background-color : var (--s-color-surface-container-highest );
50
51
border-bottom-color : var (--s-color-primary );
0 commit comments