Skip to content

Commit 423885c

Browse files
imnasnainaecalex-rawlings-yyc
authored andcommitted
Fix non-first morpheme form cell stealing focus to gloss input
Clicking a span (non-first) form cell in MorphemeBox bubbled its mousedown up to TokenChip's label handler, which only recognizes input/button targets and so treated the span as unhandled, focusing the gloss input before the popover opened.
1 parent 95387d8 commit 423885c

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/components/MorphemeBox.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,11 @@ export function MorphemeBox({
118118
key={m.id}
119119
aria-hidden="true"
120120
className={formClassName}
121-
style={formStyle}
122121
onClick={handleClick}
122+
// Not a button, so stop mousedown from bubbling to TokenChip's label handler (which
123+
// would otherwise focus the gloss input).
124+
onMouseDown={(e) => e.stopPropagation()}
125+
style={formStyle}
123126
>
124127
{m.form}
125128
</span>

src/components/TokenChip.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,10 @@ export function TokenChip({
167167
* The input is looked up by id rather than `querySelector('input')` because the morpheme gloss
168168
* inputs precede it inside the label when morphology is shown. A mouse-down on any input is left
169169
* to that input's own handling ({@link handleMouseDown} for the gloss input, which bubbles here
170-
* after already handling it); a mouse-down on a morpheme form cell or the unanalyzed "define"
171-
* trigger (all `button`s) is left to that button's own click handler, which opens the popover.
170+
* after already handling it); a mouse-down on the first morpheme form cell or the unanalyzed
171+
* "define" trigger (both real `button`s) is left to that button's own click handler. The
172+
* remaining morpheme form cells are `span`s that stop their own mousedown from bubbling here
173+
* instead (see {@link MorphemeBox}).
172174
*
173175
* @param e - The label's mouse-down event.
174176
*/

0 commit comments

Comments
 (0)