Skip to content

Commit

Permalink
Fix bug: edit related still using the old method
Browse files Browse the repository at this point in the history
  • Loading branch information
SnekNOTSnake committed Dec 6, 2022
1 parent 5b224c5 commit a6e7ef8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "my-personal-list",
"description": "My personal anime tracking list",
"version": "2.0.0",
"version": "2.1.1",
"scripts": {
"start": "concurrently \"yarn start:renderer\" \"yarn start:main\" --kill-others",
"start:main": "tsc && electron .",
Expand Down
2 changes: 1 addition & 1 deletion packages/renderer/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const Button: React.FC<Props> = ({
classNames.push(rest.className)

return (
<button {...rest} className={classNames.join(' ')}>
<button type='button' {...rest} className={classNames.join(' ')}>
<Icon />
{children && <span>{children}</span>}
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ const EditRelations: React.FC<Props> = ({ relatedI, setRelatedI, data }) => {
return filtered
}, [series, relatedInput, relatedI])

const onAddRelation = (path: string) => {
setRelatedI([...relatedI, { path, type: relatedType as any }])
const onRelatedFocus = () => {
setFocused(true)
setRelatedInput('')
}

// Related Functions
const onSetRelatedInput = (path: string) => setRelatedInput(path)
const onRemoveRelation = (path: string) => {
const index = relatedI.findIndex((el) => el.path === path)
if (index < 0) return relatedI
Expand All @@ -48,6 +51,9 @@ const EditRelations: React.FC<Props> = ({ relatedI, setRelatedI, data }) => {

setRelatedI(newRelations)
}
const onSubmitRelation = () => {
setRelatedI([...relatedI, { path: relatedInput, type: relatedType as any }])
}

return (
<div className={styles.editRelations}>
Expand All @@ -61,17 +67,17 @@ const EditRelations: React.FC<Props> = ({ relatedI, setRelatedI, data }) => {
label='Series'
value={relatedInput}
onChange={onRelatedChange}
onFocus={() => setFocused(true)}
onFocus={onRelatedFocus}
onBlur={() => setTimeout(() => setFocused(false), 100)}
/>
<Button Icon={MdOutlineAdd} />
<Button Icon={MdOutlineAdd} type='button' onClick={onSubmitRelation} />

<div
className={[styles.popover, focused ? styles.active : ''].join(' ')}
>
<ul>
{localFilteredSeries.map((s) => (
<li onClick={() => onAddRelation(s.path)} key={s.path}>
<li onClick={() => onSetRelatedInput(s.path)} key={s.path}>
{s.path}
</li>
))}
Expand Down

0 comments on commit a6e7ef8

Please sign in to comment.