Skip to content

Commit

Permalink
chore: Object.entriesは生成する配列の順序を保証しないため、ベタ書きに変える
Browse files Browse the repository at this point in the history
  • Loading branch information
AtsushiM committed Sep 13, 2024
1 parent 0b8f093 commit d31d18b
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions packages/smarthr-ui/src/components/FormControl/FormControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,24 @@ export const ActualFormControl: React.FC<Props & ElementProps> = ({
const isRoleGroup = as === 'fieldset'
const statusLabelList = Array.isArray(statusLabelProps) ? statusLabelProps : [statusLabelProps]

const describedbyIds = useMemo(
() =>
Object.entries({ helpMessage, exampleMessage, supplementaryMessage, errorMessages })
.filter(({ 1: value }) => value)
.map(([key]) => `${managedHtmlFor}_${key}`)
.join(' '),
[helpMessage, exampleMessage, supplementaryMessage, errorMessages, managedHtmlFor],
)
const describedbyIds = useMemo(() => {
const temp = []

if (helpMessage) {
temp.push(`${managedHtmlFor}_helpMessage`)
}
if (exampleMessage) {
temp.push(`${managedHtmlFor}_exampleMessage`)
}
if (supplementaryMessage) {
temp.push(`${managedHtmlFor}_supplementaryMessage`)
}
if (errorMessages) {
temp.push(`${managedHtmlFor}_errorMessages`)
}

return temp.join(' ')
}, [helpMessage, exampleMessage, supplementaryMessage, errorMessages, managedHtmlFor])
const actualErrorMessages = useMemo(() => {
if (!errorMessages) {
return []
Expand Down

0 comments on commit d31d18b

Please sign in to comment.