Skip to content

Commit 71757d8

Browse files
committed
fix(settings): rework focus/hover select cards
1 parent ce937ee commit 71757d8

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/components/views/settings/SettingsComponent.vue

+16-6
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,31 @@ const sections: Section[] = [
2020
{ title: 'menu__links', reference: ref() },
2121
];
2222
23-
const focus = ref(false);
23+
const focus = ref();
2424
const target = ref();
2525
2626
const scrollTo = (section: Section) => {
2727
target.value = section;
28-
focus.value = true;
28+
focus.value = section;
2929
section.reference?.value?.[0]?.$el?.scrollIntoView({
3030
behavior: 'smooth',
3131
block: 'center',
3232
});
3333
};
3434
35+
const onEnter = (section: Section) => {
36+
target.value = section;
37+
};
38+
39+
const onLeave = (section: Section) => {
40+
if (focus.value?.title === section?.title) {
41+
focus.value = undefined;
42+
}
43+
};
44+
3545
onDeactivated(() => {
3646
target.value = undefined;
37-
focus.value = false;
47+
focus.value = undefined;
3848
});
3949
</script>
4050

@@ -73,10 +83,10 @@ onDeactivated(() => {
7383
:ref="section.reference"
7484
:key="section.title"
7585
class="card"
76-
:class="{ target: focus && target?.title === section.title }"
86+
:class="{ target: focus?.title === section.title }"
7787
:title="i18n(section.title)"
78-
@mouseenter="target = section"
79-
@mouseleave="focus = false"
88+
@mouseenter="onEnter(section)"
89+
@mouseleave="onLeave(section)"
8090
>
8191
card Content
8292
</NCard>

0 commit comments

Comments
 (0)