Comments (5)
That is weird because the icon is inside a <li>
which has a key?
const icon = createRemoveIcon(value, index);
const tokenProps = mergeProps(
{
key: `${index}_${value}`,
id: props.inputId + '_chips_item_' + index,
role: 'option',
'aria-label': value,
className: cx('token', { focusedIndex, index }),
'aria-selected': true,
'aria-setsize': props.value.length,
'aria-posinset': index + 1,
'data-p-highlight': true,
'data-p-focused': focusedIndex === index
},
ptm('token')
);
return (
<li {...tokenProps}>
{label}
{icon}
</li>
);
from primereact.
@jnoren1 can you try my reproducer: https://stackblitz.com/edit/vitejs-vite-tfhpc2?file=src%2FApp.tsx
You missed one step {...options.iconProps}
I think https://primereact.org/customicons/#fontawesome
from primereact.
Wow, I've been using this library for about six years, and I never came across that specific piece of documentation. When we noticed the JSX indicators, we wondered if we could incorporate a custom Icon. Through trial and error it turned out we could, and we just went ahead with it without consulting the documentation. Your approach did indeed solve that issue. Miraculously, it also corrected the button callbacks, which had never quite worked as described. That's fantastic, thank you so much.
It opened up another more concerning error though. There is some typescript incompatibility going on with the size property and when forced it gave the following. I've added the callback style now to a lot of code and every single one takes issue with the size....
ProgramChips.tsx?t=1714800159507:20 Warning: Failed prop type: Invalid prop
size
of value4
supplied toFontAwesomeIcon
, expected one of ["2xs","xs","sm","lg","xl","2xl","1x","2x","3x","4x","5x","6x","7x","8x","9x","10x"].
I hacked it a wrapper function, but that does not seem ideal
removeIcon={(i) => (
<FontAwesomeIcon
{...faExProps(i.iconProps)}
key={`${program.id}-${index}`}
icon={faXmarkCircle}
className="ml-2 text-red-400 hover:text-red-950 cursor-pointer"
size={"xl"}
/>
)}
export const faExProps = (props: HTMLProps<unknown> | SVGProps<unknown>): { [key: string]: unknown; } => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { size, ...rest } = props as HTMLProps<unknown>;
return rest;
};
from primereact.
@jnoren1 that is great. Do you have a suggestion how we could update the Typescript to make it flexible right now as you know its...
Right now the Typescript is.
/**
* Icon options passed to any icon.
* ComponentProps are props from the owning component.
* AdditionalProps are any custom properties of an icon like SortIcon of the Datatable for example.
*/
export type IconOptions<ComponentProps, AdditionalProps> = AdditionalProps & {
/**
* Icon specific properties.
*/
iconProps: React.HTMLProps<any> | React.SVGProps<any>;
/**
* The element representing the icon.
*/
element: React.ReactNode;
/**
* Properties of the owning component.
*/
props?: ComponentProps;
[key: string]: any;
};
from primereact.
@jnoren1 can you check my PR I think I fixed it to FontAwesome size
property will be respected. #6579
from primereact.
Related Issues (20)
- InputOTP: Keyboard shortcut paste not working in IntegerOnly HOT 1
- DataTable > Column: It doesn't show operators dropdown and value input when dynamic column is in-place. HOT 1
- AutoComplete Input Passthrough not passing through HOT 4
- Menu: The first item remain focused even after clicking on another item. HOT 3
- Dropdown: Simple primitive values showing empty items HOT 1
- DataTable: Column Reorder Indicator Incorrect
- Calendar: Prop typings are not working correctly HOT 5
- InputNumber: number formatting does not update when locale is set through PrimeReactContext HOT 1
- IconField: Reference error React is not defined, im using vite HOT 4
- Dropdown: Init-Value not working if options have label,value properties HOT 8
- DataTable: Reordering Columns Causes Duplication in Checkbox Column and Reorder Row Indicator Column HOT 1
- Dropdown: No longer shows options with simple primitive values HOT 1
- InputOtp: Setting Value does not clear display
- Password > Icon and Input render order > tabIndex issue HOT 1
- Typo error on the Theming page HOT 1
- DataTable: re-order + resizable fails HOT 2
- Typo error on `PrimeFlex` section of the Theming documentation HOT 1
- Readme typo HOT 1
- Sidebar: Headless Sidebar is hidden in Small and Medium-Sized Views HOT 1
- PanelMenu MenuItem Id Prop Not Passed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from primereact.