switch radio away from all pets after using picker

I think it's more helpful to auto-switch: if you're using the species/color picker for pet compatibility, that's probably what you want! And it's all buffered behind the Save Changes button anyway, so nbd to play a bit fast and loose!
This commit is contained in:
Emi Matchu 2020-08-01 15:43:50 -07:00
parent 8fdc986ee9
commit fb51eeec5b

View file

@ -226,10 +226,14 @@ function ItemSupportAppearanceLayerPetCompatibility({
const biologyLayers = visibleLayers.filter((l) => l.source === "pet"); const biologyLayers = visibleLayers.filter((l) => l.source === "pet");
// When the appearance body ID changes, select it as the new body ID. (This // After we touch a species/color selector and null out `bodyId`, when the
// is an effect because it happens after the appearance finishes loading!) // appearance body ID loads in, select it as the new body ID.
//
// This might move the radio button away from "all pets", but I think that's
// a _less_ surprising experience: if you're touching the pickers, then
// that's probably where you head is.
React.useEffect(() => { React.useEffect(() => {
if (selectedBodyId !== "0") { if (selectedBodyId == null && appearanceBodyId != null) {
onChangeBodyId(appearanceBodyId); onChangeBodyId(appearanceBodyId);
} }
}, [selectedBodyId, appearanceBodyId, onChangeBodyId]); }, [selectedBodyId, appearanceBodyId, onChangeBodyId]);
@ -289,6 +293,10 @@ function ItemSupportAppearanceLayerPetCompatibility({
setSelectedBiology({ speciesId, colorId, isValid, pose }); setSelectedBiology({ speciesId, colorId, isValid, pose });
if (isValid) { if (isValid) {
onChangePreviewBiology({ speciesId, colorId, isValid, pose }); onChangePreviewBiology({ speciesId, colorId, isValid, pose });
// Also temporarily null out the body ID. We'll switch to the new
// body ID once it's loaded.
onChangeBodyId(null);
} }
}} }}
/> />