Skip to content

Commit

Permalink
fix: replace exposed site header method with nav link emitter
Browse files Browse the repository at this point in the history
  • Loading branch information
svvimming committed Sep 8, 2023
1 parent a0d14e1 commit 20329da
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions components/navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ const props = defineProps({
}
})
const instance = getCurrentInstance()
const emit = defineEmits(['nav-link-click'])
// ===================================================================== Methods
const scrollToSection = async (el) => {
instance.parent.exposed.handleNavClick()
emit('nav-link-click')
const id = el.replaceAll('#', '')
const section = document.getElementById(id)
if (section) {
Expand Down
5 changes: 2 additions & 3 deletions components/site-header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
<div class="mobile-nav">
<Navbar
:links="navigation"
class="mobile">
class="mobile"
@nav-link-click="handleNavClick">
<div class="nav-item">
<ButtonCta
tag="nuxt-link"
Expand Down Expand Up @@ -169,8 +170,6 @@ const handleNavClick = () => {
if (navigationOpen.value) { toggleNav() }
}
defineExpose({ handleNavClick })
</script>

<style lang="scss" scoped>
Expand Down

0 comments on commit 20329da

Please sign in to comment.