mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-23 11:08:07 +01:00
[Glitch] Remove the title
attribute when hovering a card anchor
Port 981395e4d6
to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
2fa3c3a748
commit
aa8ad92fa4
1 changed files with 14 additions and 1 deletions
|
@ -43,6 +43,7 @@ export const HoverCardController: React.FC = () => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let isScrolling = false;
|
let isScrolling = false;
|
||||||
let currentAnchor: HTMLElement | null = null;
|
let currentAnchor: HTMLElement | null = null;
|
||||||
|
let currentTitle: string | null = null;
|
||||||
|
|
||||||
const open = (target: HTMLElement) => {
|
const open = (target: HTMLElement) => {
|
||||||
target.setAttribute('aria-describedby', 'hover-card');
|
target.setAttribute('aria-describedby', 'hover-card');
|
||||||
|
@ -75,6 +76,9 @@ export const HoverCardController: React.FC = () => {
|
||||||
currentAnchor?.removeAttribute('aria-describedby');
|
currentAnchor?.removeAttribute('aria-describedby');
|
||||||
currentAnchor = target;
|
currentAnchor = target;
|
||||||
|
|
||||||
|
currentTitle = target.getAttribute('title');
|
||||||
|
target.removeAttribute('title');
|
||||||
|
|
||||||
setEnterTimeout(() => {
|
setEnterTimeout(() => {
|
||||||
open(target);
|
open(target);
|
||||||
}, enterDelay);
|
}, enterDelay);
|
||||||
|
@ -90,11 +94,20 @@ export const HoverCardController: React.FC = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleMouseLeave = (e: MouseEvent) => {
|
const handleMouseLeave = (e: MouseEvent) => {
|
||||||
|
const { target } = e;
|
||||||
|
|
||||||
if (!currentAnchor) {
|
if (!currentAnchor) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.target === currentAnchor || e.target === cardRef.current) {
|
if (
|
||||||
|
currentTitle &&
|
||||||
|
target instanceof HTMLElement &&
|
||||||
|
target === currentAnchor
|
||||||
|
)
|
||||||
|
target.setAttribute('title', currentTitle);
|
||||||
|
|
||||||
|
if (target === currentAnchor || target === cardRef.current) {
|
||||||
cancelEnterTimeout();
|
cancelEnterTimeout();
|
||||||
|
|
||||||
setLeaveTimeout(() => {
|
setLeaveTimeout(() => {
|
||||||
|
|
Loading…
Reference in a new issue