-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix #2620: pass standard props to the wrapping element #2708
Fix #2620: pass standard props to the wrapping element #2708
Conversation
Fixes #2620 |
Good job, @kalinkrustev ;) |
@kalinkrustev i did find one issue upgrading from 7.2.1 to 8.0.0 that maybe you can help me with. I have a custom component that I wrap PrimeReact AutoComplete like this... /**
* Properties for this component which extends PrimeReact AutoComplete.
*/
export interface ActiveDirectoryAutocompleteProps extends AutoCompleteProps {
value?: ActiveDirectoryUser | ActiveDirectoryUser[];
suggestions?: ActiveDirectoryUser[];
}
/**
* JSON object which represents the users in the dropdown.
*/
export interface ActiveDirectoryUser {
givenName?: string;
surname?: string;
jobTitle?: string;
location?: string;
}
/**
* Autocomplete for displaying users from Active Directory.
*
* @param {ActiveDirectoryAutocompleteProps} props properties to configure this component
* @returns {ActiveDirectoryAutocomplete} component
*/
export const ActiveDirectoryAutocomplete = (props: ActiveDirectoryAutocompleteProps) => {
const selectedItemTemplate = (item: ActiveDirectoryUser) => {
return `${item.firstName} ${item.lastName}`;
}
const itemTemplate = (item: ActiveDirectoryUser) => {
return (
<span className="add-user-item flex">
<div className="flex-initial flex align-items-center justify-content-center">
<LetterAvatar fullname={`${item.firstName} ${item.lastName}`} />
</div>
<div className="ml-3">
<div className="w-full">
<span className="block font-bold white-space-nowrap">{item.firstName} {item.lastName}</span>
</div>
<div style={{ color: "var(--text-color-secondary)" }}>
<span className="block text-overflow-ellipsis">{item.email} | {item.jobTitle} | {item.location}</span>
</div>
</div>
</span>
);
}
return (
<AutoComplete
selectedItemTemplate={selectedItemTemplate}
itemTemplate={itemTemplate}
delay={400}
placeholder={!props.value ? "Start typing user name" : ''}
{...props}
/>
)
} However now when I am passing
Any thoughts? The change was this export interface AutoCompleteProps extends Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, 'onChange' | 'onSelect'> { |
I did not try to extend all the components that were modified in this request. I tried adding 'ref' to export interface AutoCompleteProps extends Omit<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, 'onChange' | 'onSelect' | 'ref'> And it seems this solves the issue. |
Meanwhile I think you can do this: export const ActiveDirectoryAutocomplete = (props: Omit<ActiveDirectoryAutocompleteProps, 'ref'>) => { Until we figure out a proper fix within Primereact. |
Let me try that! |
The above looks like its working. |
Hi @melloware, |
yep! |
The approach of passing
to the wrapping div/span relies on defaultProps having all the props of
ComponentX
listed there, otherwise some props will be also passed to the wrapping div/span element. I checked if this is so for some of the components and it look it is.