Skip to content

Commit

Permalink
Merge pull request #7038 from qburst/master
Browse files Browse the repository at this point in the history
fix: #7037, Dropdown: Cannot change icon when expanding or collapsing options
  • Loading branch information
nitrogenous authored Aug 19, 2024
2 parents 2d97ede + 58f860d commit 44dee94
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
8 changes: 8 additions & 0 deletions components/doc/common/apidoc/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -23172,6 +23172,14 @@
"default": "",
"description": "Icon of the dropdown."
},
{
"name": "collapseIcon",
"optional": true,
"readonly": false,
"type": "IconType<DropdownProps>",
"default": "",
"description": "Icon of the collapse action."
},
{
"name": "editable",
"optional": true,
Expand Down
3 changes: 2 additions & 1 deletion components/lib/dropdown/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PrimeReact, { FilterService, PrimeReactContext, localeOption } from '../a
import { useHandleStyle } from '../componentbase/ComponentBase';
import { useMergeProps, useMountEffect, useOverlayListener, useUnmountEffect, useUpdateEffect } from '../hooks/Hooks';
import { ChevronDownIcon } from '../icons/chevrondown';
import { ChevronUpIcon } from '../icons/chevronup';
import { SpinnerIcon } from '../icons/spinner';
import { TimesIcon } from '../icons/times';
import { OverlayService } from '../overlayservice/OverlayService';
Expand Down Expand Up @@ -1122,7 +1123,7 @@ export const Dropdown = React.memo(
},
ptm('dropdownIcon')
);
const icon = props.dropdownIcon || <ChevronDownIcon {...dropdownIconProps} />;
const icon = !overlayVisibleState ? props.dropdownIcon || <ChevronDownIcon {...dropdownIconProps} /> : props.collapseIcon || <ChevronUpIcon {...dropdownIconProps} />;
const dropdownIcon = IconUtils.getJSXIcon(icon, { ...dropdownIconProps }, { props });

const ariaLabel = props.placeholder || props.ariaLabel;
Expand Down
1 change: 1 addition & 0 deletions components/lib/dropdown/DropdownBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export const DropdownBase = ComponentBase.extend({
dataKey: null,
disabled: false,
dropdownIcon: null,
collapseIcon: null,
editable: false,
emptyFilterMessage: null,
highlightOnSelect: true,
Expand Down
4 changes: 4 additions & 0 deletions components/lib/dropdown/dropdown.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ export interface DropdownProps extends Omit<React.DetailedHTMLProps<React.InputH
* Icon of the dropdown.
*/
dropdownIcon?: IconType<DropdownProps> | undefined;
/**
* Icon of collapse action.
*/
collapseIcon?: IconType<DropdownProps> | undefined;
/**
* When present, custom value instead of predefined options can be entered using the editable input field.
* @defaultValue false
Expand Down

0 comments on commit 44dee94

Please sign in to comment.