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

Fix: Video description collapsible and no longer hijacks page scroll #5665

Open
wants to merge 20 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
671fe01
fix: description no longer hijacks scroll focus
sabs21 Sep 7, 2024
8bba22f
fix: 'Click to View Description' button only shown for long descriptions
sabs21 Sep 8, 2024
1699c6f
Merge branch 'development' into fix_desc_scroll_steal
sabs21 Sep 16, 2024
219f827
Adjusted locale
sabs21 Sep 16, 2024
df87654
adjusted styling to closer match YT description styling; made
sabs21 Sep 16, 2024
f2e4287
updated comment within onMounted
sabs21 Sep 16, 2024
a3bf36f
...more button is now inline with description text
sabs21 Sep 16, 2024
85e025d
removed underline from description status
sabs21 Sep 23, 2024
daabdbd
Merge branch 'development' into fix_desc_scroll_steal
sabs21 Sep 23, 2024
b144302
Merge branch 'development' into fix_desc_scroll_steal_2
sabs21 Oct 3, 2024
369f9d1
Merge branch 'development' into fix_desc_scroll_steal
sabs21 Oct 3, 2024
0a6c6e5
Merge branch 'fix_desc_scroll_steal_2' into fix_desc_scroll_steal
sabs21 Oct 3, 2024
80d19bb
Merge branch 'development' into fix_desc_scroll_steal
sabs21 Oct 16, 2024
5c900f9
more... button is now accessible by tab; description overlay now igno…
sabs21 Oct 17, 2024
823d53c
readded role=button attributes
sabs21 Oct 17, 2024
861c4b9
show more and show less buttons are now tabbed to first before
sabs21 Oct 29, 2024
8a033a9
changed visual ordering of 'show less' button
sabs21 Oct 30, 2024
2acb8c7
reverted previous change; added top margin to show less button
sabs21 Oct 30, 2024
1f47f60
fixed null reference error for videos with no description
sabs21 Dec 1, 2024
f086f55
Merge branch 'development' into fix_desc_scroll_steal
sabs21 Dec 1, 2024
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
.videoDescription {
position: relative;
display: flex;
flex-direction: column;
overflow-y: auto;
max-block-size: 300px;
max-block-size: 20lh;
}

.description {
Expand All @@ -9,3 +12,46 @@
white-space: pre-wrap;
overflow-wrap: anywhere;
}

.descriptionStatus {
margin: 0;
text-decoration: underline;
cursor: pointer;
color: var(--title-color);
}

.videoDescription.short .descriptionStatus {
position: absolute;
inset-block-end: calc(1lh + 12px);
padding-block: 2px;
inset-inline-end: 16px;
padding-inline-start: 40px;
background: linear-gradient(270deg, var(--card-bg-color) 75%, transparent 100%);
text-decoration: none;
}

.videoDescription:not(.short) .descriptionStatus {
position: relative;
order: 0;
margin-block-start: 1em;
}

.videoDescription.short .description {
max-block-size: 4lh;
overflow: hidden;
}

.videoDescription:not(.short) .description {
order: 1;
}

.videoDescription .overlay {
position: absolute;
cursor: pointer;
inset: 0;
transition: background-color 200ms ease;
}

.videoDescription .overlay:hover {
background-color: var(--accent-color-opacity1);
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,40 @@
<template>
<FtCard
v-if="shownDescription.length > 0"
class="videoDescription"
:class="{ videoDescription: true, short: !showFullDescription }"
>
<template v-if="showControls">
<span
v-if="showFullDescription"
class="descriptionStatus"
role="button"
tabindex="0"
@click="collapseDescription"
@keydown.space.prevent="collapseDescription"
@keydown.enter.prevent="collapseDescription"
>
{{ $t("Description.Collapse Description") }}
</span>
<span
v-else
class="descriptionStatus"
role="button"
tabindex="0"
@keydown.space.prevent="expandDescription"
@keydown.enter.prevent="expandDescription"
>
{{ $t("Description.Expand Description") }}
</span>
<div
v-if="!showFullDescription"
class="overlay"
@click="expandDescription"
@keydown.space.prevent="expandDescription"
@keydown.enter.prevent="expandDescription"
/>
</template>
<FtTimestampCatcher
ref="descriptionContainer"
class="description"
:input-html="shownDescription"
@timestamp-event="onTimestamp"
Expand All @@ -14,6 +45,7 @@
<script setup>
import autolinker from 'autolinker'

import { onMounted, ref } from 'vue'
import FtCard from '../ft-card/ft-card.vue'
import FtTimestampCatcher from '../FtTimestampCatcher.vue'

Expand All @@ -31,6 +63,9 @@ const props = defineProps({
const emit = defineEmits(['timestamp-event'])

let shownDescription = ''
const descriptionContainer = ref()
const showFullDescription = ref(false)
const showControls = ref(false)

if (props.descriptionHtml !== '') {
const parsed = parseDescriptionHtml(props.descriptionHtml)
Expand Down Expand Up @@ -58,6 +93,37 @@ function onTimestamp(timestamp) {
emit('timestamp-event', timestamp)
}

/**
* Enables user to view entire contents of description
*/
function expandDescription() {
showFullDescription.value = true
}

/**
* Enables user to collapse contents of description
*/
function collapseDescription() {
showFullDescription.value = false
}

/**
* Returns true when description content does not overflow description container
* Useful for hiding description expansion/contraction controls
*/
function isShortDescription() {
const descriptionElem = descriptionContainer.value?.$el
return descriptionElem?.clientHeight >= descriptionElem?.scrollHeight
}

onMounted(() => {
// To verify whether or not the description is too short for displaying
// description controls, we need to check the description's dimensions.
// The only way to make this work is to check on mount.
showFullDescription.value = isShortDescription()
showControls.value = !showFullDescription.value
})

/**
* @param {string} descriptionText
* @returns {string}
Expand Down
3 changes: 3 additions & 0 deletions static/locales/en-GB.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,9 @@ Comments:
There are no comments available for this post: There are no comments available for
this post
Up Next: 'Up Next'
Description:
Expand Description: ...more
Collapse Description: Show less

# Toast Messages
Local API Error (Click to copy): 'Local API Error (Click to copy)'
Expand Down
3 changes: 3 additions & 0 deletions static/locales/en-US.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,9 @@ Comments:
Hearted: Hearted

Up Next: Up Next
Description:
Expand Description: ...more
Collapse Description: Show less

#Tooltips
Tooltips:
Expand Down