Skip to content

Commit

Permalink
Add target prop for NcListItem
Browse files Browse the repository at this point in the history
The component user should have full control over what tab
 they want the link to open in, if any.

Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
  • Loading branch information
Fenn-CS committed Dec 6, 2023
1 parent 8008811 commit bdcfe3c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/components/NcListItem/NcListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@
<a :id="anchorId"
ref="list-item"
:href="routerLinkHref || href"
:target="href === '#' ? undefined : '_blank'"
:target="computedTarget"
:rel="href === '#' ? undefined : 'noopener noreferrer'"
class="list-item"
:aria-label="linkAriaLabel"
Expand Down Expand Up @@ -470,6 +470,11 @@ export default {
default: '#',
},
target: {

Check warning on line 473 in src/components/NcListItem/NcListItem.vue

View workflow job for this annotation

GitHub Actions / eslint

Prop 'target' requires default value to be set
type: String,
required: false,
},
/**
* Id for the `<a>` element
*/
Expand Down Expand Up @@ -585,7 +590,12 @@ export default {
computedActionsAriaLabel() {
return this.actionsAriaLabel || t('Actions for item with name "{name}"', { name: this.name })
},
computedTarget() {
if (this.target !== undefined && this.target !== null) {
return this.target
}
return this.href === '#' ? undefined : '_blank'
},
},
watch: {
Expand Down

0 comments on commit bdcfe3c

Please sign in to comment.