Skip to content

Commit

Permalink
fix(select): remove duplicate event handlers and fix css conflicts
Browse files Browse the repository at this point in the history
- removes duplicate event handler declarations for onChange, onPointerDown and onBlur
- fixes duplicate max-width property in paragraph styles
- resolves merge conflict in heading line-height property
- cleans up select component structure by moving return statement outside handler
- updates css source map to resolve conflicts
  • Loading branch information
shawnsandy committed Dec 1, 2024
1 parent 4face3c commit aae10cd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 51 deletions.
65 changes: 23 additions & 42 deletions libs/react/fpkit/src/components/form/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,50 +70,31 @@ export const Select = ({

const handleOnBlur = (e: React.FocusEvent<HTMLSelectElement>) => {
if (onBlur && !disabled) onBlur?.(e)
const handleOnChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
if (onSelectionChange && !disabled) onSelectionChange?.(e)
}
const handleOnChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
if (onSelectionChange && !disabled) onSelectionChange?.(e)
}

const handlePointerDown = (e: React.PointerEvent<HTMLSelectElement>) => {
if (onPointerDown && !disabled) onPointerDown?.(e)
}
const handlePointerDown = (e: React.PointerEvent<HTMLSelectElement>) => {
if (onPointerDown && !disabled) onPointerDown?.(e)
}

const handleOnBlur = (e: React.FocusEvent<HTMLSelectElement>) => {
if (onBlur && !disabled) onBlur?.(e)
}
const handleOnBlur = (e: React.FocusEvent<HTMLSelectElement>) => {
if (onBlur && !disabled) onBlur?.(e)
}

return (
<UI
as="select"
id={id}
ref={ref}
name={name}
className={classes}
selected={selected}
onChange={handleOnChange}
onPointerDown={handlePointerDown}
onBlur={handleOnBlur}
required={required}
aria-required={required} // Accessibility
disabled={disabled}
aria-disabled={disabled ? true : false}
style={styles}
{...props} // Accessibility
>
<option value="" />
</UI>
)
}

return (
<UI
as="select"
id={id}
ref={ref}
name={name}
className={classes}
selected={selected}
onChange={handleOnChange}
onPointerDown={handlePointerDown}
onBlur={handleOnBlur}
required={required}
aria-required={required} // Accessibility
disabled={disabled}
aria-disabled={disabled ? true : false}
style={styles}
{...props} // Accessibility
>
<option value="" />
</UI>
)
}

export default Select
Select.displayName = 'Select' // Remove this line
Select.Option = Option // Remove this line
Expand Down
5 changes: 1 addition & 4 deletions libs/react/fpkit/src/styles/index.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit aae10cd

Please sign in to comment.