Skip to content

Commit

Permalink
fix(player): restart keyboard display animations on key press
Browse files Browse the repository at this point in the history
  • Loading branch information
mihar-22 committed Feb 17, 2024
1 parent 5f5d40a commit 2376735
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ const DefaultVideoKeyboardActionDisplay = React.forwardRef<
>(({ icons: Icons, translations, ...props }, forwardRef) => {
const [visible, setVisible] = React.useState(false),
[Icon, setIcon] = React.useState<any>(null),
[count, setCount] = React.useState(0),
$lastKeyboardAction = useMediaState('lastKeyboardAction');

React.useEffect(() => {
setCount((n) => n + 1);
}, [$lastKeyboardAction]);

const actionDataAttr = React.useMemo(() => {
const action = $lastKeyboardAction?.action;
return action && visible ? camelToKebabCase(action) : null;
Expand Down Expand Up @@ -76,13 +81,12 @@ const DefaultVideoKeyboardActionDisplay = React.forwardRef<
className={className}
data-action={actionDataAttr}
ref={forwardRef as any}
key={$lastKeyboardAction}
>
<div className="vds-kb-text-wrapper">
<div className="vds-kb-text">{$text}</div>
</div>
{Icon ? (
<div className="vds-kb-bezel" role="status" aria-label={$statusLabel}>
<div className="vds-kb-bezel" role="status" aria-label={$statusLabel} key={count}>
<div className="vds-kb-icon">
<Icon />
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { html } from 'lit-html';
import { keyed } from 'lit-html/directives/keyed.js';
import { computed, effect, signal } from 'maverick.js';
import { camelToKebabCase } from 'maverick.js/std';

Expand Down Expand Up @@ -55,7 +56,7 @@ export function DefaultVideoKeyboardActionDisplay() {
<div class="vds-kb-text-wrapper">
<div class="vds-kb-text">${$signal($text)}</div>
</div>
${$signal(Icon)}
${$signal(() => keyed(lastKeyboardAction(), Icon()))}
</div>
`;
});
Expand Down

0 comments on commit 2376735

Please sign in to comment.