Skip to content

Commit

Permalink
refactor(files): replace deprecated is attr on <a> with dynamic c…
Browse files Browse the repository at this point in the history
…omponent

- Special attribute `is` is deprecated and removed in Vue 3
- It is confusing, that `<a>` element is rendered as `span` sometimes

Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
  • Loading branch information
ShGKme committed Jan 8, 2024
1 parent 3ff2b25 commit 5522000
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions apps/files/src/components/FileEntry/FileEntryName.vue
Expand Up @@ -37,20 +37,21 @@
@keyup.esc="stopRenaming" />
</form>

<a v-else
<component :is="linkTo.is"
v-else
ref="basename"
:aria-hidden="isRenaming"
class="files-list__row-name-link"
data-cy-files-list-row-name-link
v-bind="linkTo"
v-bind="linkTo.params"
@click="$emit('click', $event)">
<!-- File name -->
<span class="files-list__row-name-text">
<!-- Keep the displayName stuck to the extension to avoid whitespace rendering issues-->
<span class="files-list__row-name-" v-text="displayName" />
<span class="files-list__row-name-ext" v-text="extension" />
</span>
</a>
</component>
</template>

<script lang="ts">
Expand Down Expand Up @@ -139,8 +140,10 @@ export default Vue.extend({
linkTo() {
if (this.source.attributes.failed) {
return {
title: t('files', 'This node is unavailable'),
is: 'span',
params: {
title: t('files', 'This node is unavailable'),
},
}
}
Expand All @@ -149,18 +152,24 @@ export default Vue.extend({
const action = enabledDefaultActions[0]
const displayName = action.displayName([this.source], this.currentView)
return {
title: displayName,
role: 'button',
tabindex: '0',
is: 'a',
params: {
title: displayName,
role: 'button',
tabindex: '0',
},
}
}
if (this.source?.permissions & Permission.READ) {
return {
download: this.source.basename,
href: this.source.source,
title: t('files', 'Download file {name}', { name: this.displayName }),
tabindex: '0',
is: 'a',
params: {
download: this.source.basename,
href: this.source.source,
title: t('files', 'Download file {name}', { name: this.displayName }),
tabindex: '0',
},
}
}
Expand Down

0 comments on commit 5522000

Please sign in to comment.