Skip to content

Commit

Permalink
Merge pull request #147 from dragoni7/remember-subclass-modification-…
Browse files Browse the repository at this point in the history
…in-dashboard

Add condition to prevent resetting subclass on opening
  • Loading branch information
dragoni7 authored Oct 18, 2024
2 parents 19a7242 + 9f08e64 commit 4d85f64
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/app/routes/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -429,17 +429,19 @@ export const Dashboard: React.FC = () => {
}
};

const handleSubclassRightClick = (subclass: SubclassConfig) => {
const handleSubclassOpen = (subclass: SubclassConfig) => {
setCustomizingSubclass(subclass);
setShowAbilitiesModification(true);
};

const subclassColor = useMemo(() => {
if (selectedSubclass) {
const damageTypeName = DAMAGE_TYPE[selectedSubclass.damageType].toLowerCase();
return subclassColors[damageTypeName] || subclassColors.kinetic;
}
return subclassColors.kinetic;
}, [selectedSubclass]);

return (
<>
{showAbilitiesModification && customizingSubclass ? (
Expand Down Expand Up @@ -481,7 +483,7 @@ export const Dashboard: React.FC = () => {
subclasses={subclasses}
selectedSubclass={selectedSubclass}
onSubclassSelect={handleSubclassSelect}
onSubclassOpen={handleSubclassRightClick}
onSubclassOpen={handleSubclassOpen}
/>
</Box>
<NumberBoxes maxReachableValues={maxReachableValues} />
Expand Down
7 changes: 5 additions & 2 deletions src/features/subclass/components/SubclassSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,11 @@ const SubclassSelector: React.FC<SubclassSelectorProps> = React.memo(
isSelected={isSelected}
isCenter={isCenter}
onClick={(event) => {
handleSelect(subclass);
if (subclass === selectedSubclass) handleOpenSubclass(event, subclass);
if (subclass === selectedSubclass) {
handleOpenSubclass(event, subclass);
} else {
handleSelect(subclass);
}
}}
style={{ gridArea: gridPositions[index] }}
onMouseEnter={() => setHoveredSubclass(subclass)}
Expand Down

0 comments on commit 4d85f64

Please sign in to comment.