diff --git a/src/app/WardrobePage/OutfitControls.js b/src/app/WardrobePage/OutfitControls.js index b0c67be..6278abc 100644 --- a/src/app/WardrobePage/OutfitControls.js +++ b/src/app/WardrobePage/OutfitControls.js @@ -62,6 +62,14 @@ function OutfitControls({ outfitState, dispatchToOutfit }) { [dispatchToOutfit, toast] ); + const maybeUnlockFocus = (e) => { + // We lock focus when a touch-device user taps the area. When they tap + // empty space, we treat that as a toggle and release the focus lock. + if (e.target === e.currentTarget) { + onUnlockFocus(); + } + }; + return ( { + const opacity = parseFloat(getComputedStyle(e.currentTarget).opacity); + if (opacity < 0.5) { + // If the controls aren't visible right now, then clicks on them are + // probably accidental. Ignore them! (We prevent default to block + // built-in behaviors like link nav, and we stop propagation to block + // our own custom click handlers. I don't know if I can prevent the + // select clicks though?) + e.preventDefault(); + e.stopPropagation(); + + // We also show the controls, by locking focus. We'll undo this when + // the user taps elsewhere (because it will trigger a blur event from + // our child components), in `maybeUnlockFocus`. + setFocusIsLocked(true); + } + }} > - + @@ -114,8 +147,8 @@ function OutfitControls({ outfitState, dispatchToOutfit }) { - - + + {/** * We try to center the species/color picker, but the left spacer will * shrink more than the pose picker container if we run out of space!