Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add replace prop to KRouterLink #152

Merged
merged 2 commits into from
Feb 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion lib/buttons-and-links/KRouterLink.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<template>

<!-- no extra whitespace inside link -->
<router-link :class="buttonClasses" :to="to" dir="auto">
<router-link
:class="buttonClasses"
:to="to"
:replace="replace"
dir="auto"
>
<KLabeledIcon :maxWidth="maxWidth" @mouseenter="hovering = true" @mouseleave="hovering = false">
<KIcon
v-if="icon"
Expand Down Expand Up @@ -54,6 +59,13 @@
type: String,
required: false,
},
/**
* If provided, calls window.history.replaceState() so navigation will not leave history record
*/
replace: {
type: Boolean,
required: false,
},
Comment on lines +65 to +68
Copy link
Contributor

@indirectlylit indirectlylit Feb 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid ambiguity and undefined input values, component props should either be required: true or provide a default value.

In this case, the prop should be:

      replace: {
        type: Boolean,
        default: false,
      }

This ought to be caught by a linting rule. Can follow up separately on why it wasn't:
https://eslint.vuejs.org/rules/require-default-prop.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I fixed it in a separate branch as a PR #162. Here. Not sure why that wasn't caught?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I missed that - good eye @indirectlylit !

/**
* If provided, shows a KIcon after the text
*/
Expand Down