lostcarpark / conclar

ConClár Programme Guide in ReactJS
MIT License
11 stars 12 forks source link

Can't select text in items #90

Closed mcdemarco closed 2 years ago

mcdemarco commented 2 years ago

In a context where the item is collapsible, it collapses on mouseup when trying to select text with the mouse. This behavior includes the title and participants, and is unexpected. It was still happening for me on main as of today.

I sent the user who had this problem to our non-interactive version of the schedule. Another workaround is to visit the item permalink.

lostcarpark commented 2 years ago

One easy fix would be to change the target for expanding/contracting from the whole title area to the expand/collapse indicator on the right. However, that's giving a very small target area, particularly on mobile devices.

A more sophisticated solution would be to try to distinguish between tapping/clicking and dragging.

Any thoughts?

lostcarpark commented 2 years ago

So the following returns the current selection: window.getSelection().toString() So if you just clicked, selection should be emptied, but if the selection contains text, it means the click was from a selection rather than a single click. I think adding this check before the collapse might be sufficient. I've been testing on desktop, and it seems to work well. I haven't tested on mobile yet.

mcdemarco commented 2 years ago

I think it shouldn't be happening at all, but it's hard to track down why it is happening because React puts all the event handlers on the whole body. If it doesn't cause other issues then I guess a workaround would work.

lostcarpark commented 2 years ago

I think #91 resolves this. Let me know what you think.