Skip to content

Commit

Permalink
Merge pull request #229 from taichushouwang/fix
Browse files Browse the repository at this point in the history
Fix Bug
  • Loading branch information
guansss authored Nov 21, 2023
2 parents b5aa81b + 896bb61 commit 570b35f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { SetOptional } from 'type-fest'
import { EditorFieldProps } from 'components/editor/EditorFieldProps'
import type { CopilotDocV1 } from 'models/copilot.schema'

import { operatorDirections } from '../../../models/operator'
import { OperatorDirection, operatorDirections } from '../../../models/operator'
import { FormField2 } from '../../FormField'

interface EditorActionOperatorDirectionProps
Expand Down Expand Up @@ -41,8 +41,9 @@ export const EditorActionOperatorDirection = ({
error={errors[name]}
description="部署干员的干员朝向"
>
<Select2
<Select2<OperatorDirection>
filterable={false}
resetOnSelect={true}
items={operatorDirections}
itemRenderer={(action, { handleClick, handleFocus, modifiers }) => (
<MenuItem
Expand Down
4 changes: 2 additions & 2 deletions src/components/editor/operator/EditorOperator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const EditorOperatorName = <T extends FieldValues>({
query ? fuse.search(query).map((el) => el.item) : items
}
fieldState={fieldState}
onReset={() => onChange(undefined)}
onReset={() => onChange('')}
itemRenderer={(item, { handleClick, handleFocus, modifiers }) => (
<MenuItem
key={item.name}
Expand All @@ -88,7 +88,7 @@ export const EditorOperatorName = <T extends FieldValues>({
/>
)}
onItemSelect={(item) => onChange(item.name)}
selectedItem={createArbitraryOperator(value as string)}
selectedItem={createArbitraryOperator((value || '') as string)}
inputValueRenderer={(item) => item.name}
createNewItemFromQuery={(query) => createArbitraryOperator(query)}
createNewItemRenderer={(query, active, handleClick) => (
Expand Down
6 changes: 3 additions & 3 deletions src/components/editor/operator/EditorOperatorSkill.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ interface EditorOperatorSkillChoice {
title: string
value: number | null
}
const EditorOperatorSkillSelect = Select2.ofType<EditorOperatorSkillChoice>()

interface EditorOperatorSkillProps
extends EditorFieldProps<CopilotDocV1.Operator, number> {}
Expand Down Expand Up @@ -52,8 +51,9 @@ export const EditorOperatorSkill = ({
const selected = items.find((item) => item.value === (value ?? 1))

return (
<EditorOperatorSkillSelect
<Select2<EditorOperatorSkillChoice>
filterable={false}
resetOnSelect={true}
items={items}
itemRenderer={(action, { handleClick, handleFocus, modifiers }) => (
<MenuItem
Expand All @@ -76,6 +76,6 @@ export const EditorOperatorSkill = ({
onBlur={onBlur}
ref={ref}
/>
</EditorOperatorSkillSelect>
</Select2>
)
}
9 changes: 4 additions & 5 deletions src/components/editor/operator/EditorPerformerAdd.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const EditorPerformerAdd: FC<EditorPerformerAddProps> = ({
submitOperator,
submitGroup,
}) => {
const activeItem =
const selectedItem =
performerSelectItems.find((item) => item.value === mode) ||
performerSelectItems[0]

Expand All @@ -59,20 +59,19 @@ export const EditorPerformerAdd: FC<EditorPerformerAddProps> = ({
items={performerSelectItems}
className="ml-1"
onItemSelect={(e) => onModeChange(e.value)}
itemRenderer={(action, { handleClick, handleFocus, modifiers }) => (
itemRenderer={(action, { handleClick, handleFocus }) => (
<MenuItem
key={action.value}
selected={modifiers.active}
selected={action.value === mode}
onClick={handleClick}
onFocus={handleFocus}
text={action.label}
/>
)}
activeItem={activeItem}
>
<Button
large
text={activeItem.label}
text={selectedItem.label}
rightIcon="double-caret-vertical"
/>
</Select2>
Expand Down

0 comments on commit 570b35f

Please sign in to comment.