Mastodon Alt-text

For support with specific websites

Moderator: trava90

Forum rules
Please always mention the name/domain of the website in question in your topic title.
Please one website per topic thread (to help keep things organized). While behavior on different sites might at first glance seem similar, they are not necessarily caused by the same.

Please try to include any relevant output from the Toolkit Error Console or the Developer Tools Web Console using the following procedure:
  1. Clear any current output
  2. Navigate or refresh the page in question
  3. Copy and paste Errors or seemingly relevant Warnings into a single [ code ] block.
User avatar
Squirrel42
Apollo supporter
Apollo supporter
Posts: 30
Joined: 2020-07-24, 08:54

Mastodon Alt-text

Post by Squirrel42 » 2025-08-05, 16:32

For example at https://chaos.social/@offermann/114975628745666025 there should be access to the alt-text for the image. It does not show on mouse over (as it used to be in at least Pale Moon 33.7), and it does not show on clicking the "ALT" (as in Firefox). Right-click and "View Image Info" does show the alt-text, but that is quite slow to get there, in comparison to mouse over/ALT-click.

Toolkit Error Console:

Code: Select all

Timestamp: 05.08.2025 18:23:37
Warning: Content Security Policy: Couldn’t parse invalid host 'wasm-unsafe-eval'
does not seem to be related to this.

Code: Select all

<meta content="Ein doppelter Regenbogen über Feldern im Münsterland. Rechts befindet sich ein Maisfeld, links ein Stoppelacker. Dazwischen verläuft ein Feldweg, der rechts mit Apfelbäumen bestanden ist. Der vorderste Apfelbaum berührt scheinbar fast den Regenbogen und sitzt voller tief roter Äpfel. Am Horizont sieht man einen klein abgebildeten Laubwalt, der sonnig beschienen ist." property="og:image:alt">

vannilla
Moon Magic practitioner
Moon Magic practitioner
Posts: 2522
Joined: 2018-05-05, 13:29

Re: Mastodon Alt-text

Post by vannilla » 2025-08-05, 16:43

Seems to be some ReactJS nonsense with event handlers, I could not go any further.

User avatar
Moonchild
Project founder
Project founder
Posts: 38829
Joined: 2011-08-28, 17:27
Location: Sweden

Re: Mastodon Alt-text

Post by Moonchild » 2025-08-05, 19:41

"Why use built-in core HTML functionality when you can (slowly) emulate it with JavaScript, instead?"
Sorry for the rhetorical question. But it really is something I've asked myself more and more, and not just when dealing with this kind of thing.
Completely styled tooltips need no scripting. Just html and css.

I never really understood the whole "ALT" visual button thing anyway. The ALT attribute on an image is there to provide a text description of the image for devices that can't display the image (e.g. accessibility or limited resource machines or text terminals or user choice to not download more than the core document right away). i.e. it's there to provide meaningful content where the image itself is suppressed. It's not supposed to be there in addition to the image.
"There is no point in arguing with an idiot, because then you're both idiots." - Anonymous
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

Kris_88
Board Warrior
Board Warrior
Posts: 1168
Joined: 2021-01-26, 11:18

Re: Mastodon Alt-text

Post by Kris_88 » 2025-08-05, 20:21

It seems that this is a bug in Mastodon. Although, I will not dig into it to the end, let Mastodon experts do it better.
The problem is probably in the alt_text_badge.tsx or useSelectableClick.ts module.

If we remove the line "setOpen(false);", the ALT button works as expected.
It would be easy to make a filter for Modify HTTP Response, but I don't see much point in it.

alt_text_badge.tsx :

Code: Select all

import { useState, useCallback, useRef, useId } from 'react';

import { FormattedMessage } from 'react-intl';

import Overlay from 'react-overlays/Overlay';
import type {
  OffsetValue,
  UsePopperOptions,
} from 'react-overlays/esm/usePopper';

import { useSelectableClick } from 'mastodon/hooks/useSelectableClick';

const offset = [0, 4] as OffsetValue;
const popperConfig = { strategy: 'fixed' } as UsePopperOptions;

export const AltTextBadge: React.FC<{
  description: string;
}> = ({ description }) => {
  const accessibilityId = useId();
  const anchorRef = useRef<HTMLButtonElement>(null);
  const [open, setOpen] = useState(false);

  const handleClick = useCallback(() => {
    setOpen((v) => !v);
  }, [setOpen]);

  const handleClose = useCallback(() => {
    setOpen(false);
  }, [setOpen]);

  const [handleMouseDown, handleMouseUp] = useSelectableClick(handleClose);

  return (
    <>
      <button
        type='button'
        ref={anchorRef}
        className='media-gallery__alt__label'
        onClick={handleClick}
        aria-expanded={open}
        aria-controls={accessibilityId}
      >
        ALT
      </button>

      <Overlay
        rootClose
        onHide={handleClose}
        show={open}
        target={anchorRef.current}
        placement='top-end'
        flip
        offset={offset}
        popperConfig={popperConfig}
      >
        {({ props }) => (
          <div {...props} className='hover-card-controller'>
            <div // eslint-disable-line jsx-a11y/no-noninteractive-element-interactions
              className='media-gallery__alt__popover dropdown-animation'
              role='region'
              id={accessibilityId}
              onMouseDown={handleMouseDown}
              onMouseUp={handleMouseUp}
            >
              <h4>
                <FormattedMessage
                  id='alt_text_badge.title'
                  defaultMessage='Alt text'
                />
              </h4>
              <p>{description}</p>
            </div>
          </div>
        )}
      </Overlay>
    </>
  );
};

Kris_88
Board Warrior
Board Warrior
Posts: 1168
Joined: 2021-01-26, 11:18

Re: Mastodon Alt-text

Post by Kris_88 » 2025-08-05, 20:51

There is an assumption that the Click, MouseDown, MouseUp events are not generated in the order that Mastodon expects, or some fields in the Event objects are not filled in the way that Mastodon expects.

Here is a filter for Modify HTTP Response, but it will probably become irrelevant when the site scripts are updated.

Code: Select all

[["chaos.social",["/packs/alt_text_badge-BpXb2IW4.js",["t(!1)",""]]]]

Kris_88
Board Warrior
Board Warrior
Posts: 1168
Joined: 2021-01-26, 11:18

Re: Mastodon Alt-text

Post by Kris_88 » 2025-08-06, 13:54

Moonchild wrote:
2025-08-05, 19:41
"Why use built-in core HTML functionality when you can (slowly) emulate it with JavaScript, instead?"
Self-Operating Napkin
Image

Kris_88
Board Warrior
Board Warrior
Posts: 1168
Joined: 2021-01-26, 11:18

Re: Mastodon Alt-text

Post by Kris_88 » 2025-08-07, 08:55

https://github.com/react-bootstrap/reac ... ose.ts#L76

In short, the Click event that opens the alt-text popup then immediately closes it, because this Click is outside the popup area and, according to the authors' idea, should close it.
The question remains about the order of triggering two handlers for the same event: why does this work in MS Edge? Interestingly, this sometimes works in Pale Moon too. Apparently, there is some dependence on the speed of scripts and additional pollyfills that can change the order of response to events.

Does anyone want to report the problem to Mastodon or React developers?

User avatar
Moonchild
Project founder
Project founder
Posts: 38829
Joined: 2011-08-28, 17:27
Location: Sweden

Re: Mastodon Alt-text

Post by Moonchild » 2025-08-07, 09:06

So they are having a race condition. Great job, devs [/sarcasm]
"There is no point in arguing with an idiot, because then you're both idiots." - Anonymous
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

Kris_88
Board Warrior
Board Warrior
Posts: 1168
Joined: 2021-01-26, 11:18

Re: Mastodon Alt-text

Post by Kris_88 » 2025-08-08, 16:29

Ok, I found the deepest cause of the problem.
This is the same useRootClose() function, which should close the popup when clicked outside its area, and it works differently in MS Edge than in Pale Moon.

https://github.com/react-bootstrap/reac ... ose.ts#L91
let currentEvent = window.event;

React uses window.event and if it doesn't work, then many similar problems with event handling can happen.

The window.event needs to be enabled in about:config:

Code: Select all

dom.window.event.enabled = true
@Moonchild
And maybe it makes sense to allow it by default.

User avatar
Moonchild
Project founder
Project founder
Posts: 38829
Joined: 2011-08-28, 17:27
Location: Sweden

Re: Mastodon Alt-text

Post by Moonchild » 2025-08-08, 18:58

Kris_88 wrote:
2025-08-08, 16:29
And maybe it makes sense to allow it by default.
No, it does not.
MDN wrote:Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
MDN wrote:Note: This property can be fragile, in that there may be situations in which the returned Event is not the expected value. In addition, Window.event is not accurate for events dispatched within shadow trees.
As for the root cause being this:
Kris_88 wrote:
2025-08-08, 16:29
let currentEvent = window.event;
This will be terrible practice anyway since window.event does not survive scope changes even in browsers that support window.event by default. (see fragile remark above)
React uses window.event and if it doesn't work, then many similar problems with event handling can happen.
Then this needs to be reported as a bug to the React devs.
"There is no point in arguing with an idiot, because then you're both idiots." - Anonymous
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

Kris_88
Board Warrior
Board Warrior
Posts: 1168
Joined: 2021-01-26, 11:18

Re: Mastodon Alt-text

Post by Kris_88 » 2025-08-08, 19:49

Moonchild wrote:
2025-08-08, 18:58
Kris_88 wrote:
2025-08-08, 16:29
And maybe it makes sense to allow it by default.
No, it does not.
Well, as you wish...

At least we now know what to try if a React-related site is not working in Pale Moon. Given that there are no error messages in the Console, this was quite difficult to find...

Actually, I expected, for a start, something like this:
"Thanks, Kris, for finding the cause of the problem, which can potentially affect the functionality of many sites with Pale Moon."
And then everything else...

As for communicating with the react-bootstrap developers, I leave that to others who want to.

User avatar
Moonchild
Project founder
Project founder
Posts: 38829
Joined: 2011-08-28, 17:27
Location: Sweden

Re: Mastodon Alt-text

Post by Moonchild » 2025-08-08, 21:13

Kris_88 wrote:
2025-08-08, 19:49
Actually, I expected, for a start, something like this:
So you wanted a pat on the back and are now sour because I didn't immediately give it, not knowing it was very difficult to find?

I mean, I do appreciate you looking into it and I'm glad you found the likely cause and a possible solution here, but demanding public praise immediately is... a little weird of a thing to do (and me doing so now would just feel just as weird, after you spelled out the expectation) :roll:

But I do not want to make a workaround that is enabling fragile IE quirk default. We've had good past experience with webmasters making use of window.event in the past seeing it is in fact not a good thing to use and easy to solve (even in react they are passing the event into the handler, so they can just use it...). And it is only impacting multiple sites because react is a framework (and their devs should know better). The only situation in which it makes sense to enable it by default if react devs absolutely refuse to fix their code and it continues to impact sites using the framework, for web compatibility reasons. But first things first: it needs to be brought up with the devs.
Kris_88 wrote:
2025-08-08, 19:49
As for communicating with the react-bootstrap developers, I leave that to others who want to.
I guess you're gonna just be sour then. Okay. :wave:

EDIT: Issue created.
"There is no point in arguing with an idiot, because then you're both idiots." - Anonymous
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

Kris_88
Board Warrior
Board Warrior
Posts: 1168
Joined: 2021-01-26, 11:18

Re: Mastodon Alt-text

Post by Kris_88 » 2025-08-08, 22:16

Moonchild wrote:
2025-08-08, 21:13
So you wanted a pat on the back and are now sour because I didn't immediately give it, not knowing it was very difficult to find?
Yes, that would be normal. It's nice to hear "thank you", if, of course, it's justified.
And after that - critical remarks... :D
Moonchild wrote:
2025-08-08, 21:13
I guess you're gonna just be sour then. Okay. :wave:
Definitely not. Why should I? ...
Moonchild wrote:
2025-08-08, 21:13
Issue created.
Good.
Thank you.

Kris_88
Board Warrior
Board Warrior
Posts: 1168
Joined: 2021-01-26, 11:18

Re: Mastodon Alt-text

Post by Kris_88 » 2025-08-09, 01:52

Actually, the chances of them fixing the problem are pretty low.
The "Mastodon" project uses "react-overlays", but "react-overlays" is no longer maintained.
And "Mastodon" itself has 4K open issues...

https://github.com/mastodon/mastodon/ne ... t-overlays
https://github.com/react-bootstrap/reac ... 1468843066

User avatar
Moonchild
Project founder
Project founder
Posts: 38829
Joined: 2011-08-28, 17:27
Location: Sweden

Re: Mastodon Alt-text

Post by Moonchild » 2025-08-09, 09:24

Kris_88 wrote:
2025-08-09, 01:52
The "Mastodon" project uses "react-overlays", but "react-overlays" is no longer maintained.
That's unfortunate.
Kris_88 wrote:
2025-08-09, 01:52
And "Mastodon" itself has 4K open issues...
So begs the question then why webmasters are using it to begin with. ;)
"There is no point in arguing with an idiot, because then you're both idiots." - Anonymous
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite