FIXED: Icon button with toggle
This commit is contained in:
@@ -44,21 +44,18 @@ export const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(
|
||||
|
||||
const buttonRef = useRef<HTMLButtonElement>(null);
|
||||
|
||||
const callback = useCallback(
|
||||
() => (event: MouseEventHandler<HTMLButtonElement>) => {
|
||||
if (toggled) {
|
||||
if (toggleIcon.state === 'selected') {
|
||||
toggle('', toggled.unselected ?? 'add_circle');
|
||||
} else {
|
||||
toggle('selected', toggled.selected ?? 'add_circle');
|
||||
}
|
||||
const callback = event => {
|
||||
if (toggled) {
|
||||
if (toggleIcon.state === 'selected') {
|
||||
toggle('', toggled.unselected ?? 'add_circle');
|
||||
} else {
|
||||
toggle('selected', toggled.selected ?? 'add_circle');
|
||||
}
|
||||
if (props.onClick) {
|
||||
props.onClick.apply(null, event);
|
||||
}
|
||||
},
|
||||
[toggleIcon],
|
||||
);
|
||||
}
|
||||
if (props.onClick) {
|
||||
props.onClick.apply(null, event);
|
||||
}
|
||||
};
|
||||
|
||||
useImperativeHandle(ref, () => buttonRef.current);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user