Skip to content

Commit

Permalink
fix: small fix for id attribute generation
Browse files Browse the repository at this point in the history
transform ' ' to '-'
  • Loading branch information
hyrsky committed Mar 4, 2020
1 parent 71ed7a3 commit 779a19d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export function useWebformElement<T extends {}>(element: WebformElement, options
}

export function getOptionId(name: string, value: string) {
return `form-${name.replace('_', '-')}-${value.toLowerCase().replace('_', '-')}`
return `form-${name}-${value.toLowerCase()}`.replace(/[_\s]/g, '-')
}

/**
Expand All @@ -210,7 +210,7 @@ export function getOptionId(name: string, value: string) {
* @param name element name
*/
export function getElementId(name: string) {
return `form-${name.replace('_', '-')}`
return `form-${name}`.replace(/[_\s]/g, '-')
}

/**
Expand Down

0 comments on commit 779a19d

Please sign in to comment.