-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: rework Select to use reactstrap implementation #970
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review pass
src/Select/Select.tsx
Outdated
import React, { ChangeEvent, ReactElement } from 'react'; | ||
import { Input } from 'reactstrap'; | ||
|
||
export interface SelectProps { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should extends the native HTML select element props, similar to the Input component:
design-react-kit/src/Input/Input.tsx
Line 50 in 23bed3f
export interface InputProps extends InputHTMLAttributes<HTMLInputElement> { |
Something like:
export interface SelectProps { | |
export interface SelectProps extends HTMLSelectAttributes<HTMLSelectElement> { | |
src/Select/Select.tsx
Outdated
/** | ||
* L'identificativo univoco del componente | ||
*/ | ||
id: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not required if extending the native element
src/Select/Select.tsx
Outdated
* @param selectedValue | ||
* @returns | ||
*/ | ||
handleChange: (selectedValue: string) => void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handleChange: (selectedValue: string) => void; | |
onChange: (selectedValue: string) => void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with this is that SelectHTMLAttributes
already has an onChange
property with a different signature, which accepts an event instead of a string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, it has also a handleChange
, I found a way to override it but it's not really elegant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I implemented the aforementioned way to override the signature (using Omit<K,V>
) but feel free to to suggest better alternatives
src/Select/Select.tsx
Outdated
</div> | ||
); | ||
export const Select = ({ | ||
id = 'select', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is not a good idea to have a default id value, as id
is something that should be unique in a DOM tree.
If the only reason to have it is to use it as reference for the label
tag, I could suggest branching the rendering based on the id
value:
- if none is passed, then the
label
tag will wrap theInput
component - otherwise use the current structure (without the
-select
suffix)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you, my bad for not knowing label
could wrap its component
Also, need to add a note on the |
I think this belongs to another PR, since nobody has started writing it yet, not even for already implemented features. |
docs have still to be updated but examples work
Co-authored-by: Marco Liberati <[email protected]>
Co-authored-by: Marco Liberati <[email protected]>
339075f
to
cca3785
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is okay for me
Fixes #914
PR Checklist
master
branch.Short description of what this resolves:
Changes proposed in this Pull Request: