Skip to content

Commit

Permalink
Fix primefaces#4348: Dropdown optionGroupChildren fix
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed May 8, 2023
1 parent 6f0dd86 commit deef231
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 9 deletions.
8 changes: 4 additions & 4 deletions components/lib/dropdown/Dropdown.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as React from 'react';
import PrimeReact, { FilterService } from '../api/Api';
import { useMountEffect, useOverlayListener, useUnmountEffect, useUpdateEffect } from '../hooks/Hooks';
import { ChevronDownIcon } from '../icons/chevrondown';
import { TimesIcon } from '../icons/times';
import { OverlayService } from '../overlayservice/OverlayService';
import { Tooltip } from '../tooltip/Tooltip';
import { classNames, DomHandler, IconUtils, ObjectUtils, ZIndexUtils } from '../utils/Utils';
import { DomHandler, IconUtils, ObjectUtils, ZIndexUtils, classNames } from '../utils/Utils';
import { DropdownBase } from './DropdownBase';
import { DropdownPanel } from './DropdownPanel';
import { ChevronDownIcon } from '../icons/chevrondown';
import { TimesIcon } from '../icons/times';

export const Dropdown = React.memo(
React.forwardRef((inProps, ref) => {
Expand Down Expand Up @@ -50,7 +50,7 @@ export const Dropdown = React.memo(
let filteredSubOptions = FilterService.filter(getOptionGroupChildren(optgroup), searchFields, filterValue, props.filterMatchMode, props.filterLocale);

if (filteredSubOptions && filteredSubOptions.length) {
filteredGroups.push({ ...optgroup, ...{ items: filteredSubOptions } });
filteredGroups.push({ ...optgroup, ...{ [`${props.optionGroupChildren}`]: filteredSubOptions } });
}
}

Expand Down
2 changes: 1 addition & 1 deletion components/lib/dropdown/DropdownBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const DropdownBase = {
onMouseDown: null,
onShow: null,
optionDisabled: null,
optionGroupChildren: null,
optionGroupChildren: 'items',
optionGroupLabel: null,
optionGroupTemplate: null,
optionLabel: null,
Expand Down
1 change: 1 addition & 0 deletions components/lib/dropdown/dropdown.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ export interface DropdownProps extends Omit<React.DetailedHTMLProps<React.InputH
optionDisabled?: string | ((option: any) => boolean) | undefined;
/**
* Property name or getter function that refers to the children options of option group.
* @defaultValue items
*/
optionGroupChildren?: string | undefined;
/**
Expand Down
6 changes: 3 additions & 3 deletions components/lib/scrolltop/ScrollTop.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,20 @@ export const ScrollTop = React.memo(
className: iconClassName
},
ptm('icon')
)
);
const icon = props.icon || <ChevronUpIcon {...iconProps} />;
const scrollIcon = IconUtils.getJSXIcon(icon, { ...iconProps }, { props });
const rootProps = mergeProps(
{
ref: scrollElementRef,
type: "button",
type: 'button',
className,
style: props.style,
onClick
},
ScrollTopBase.getOtherProps(props),
ptm('root')
)
);

return (
<>
Expand Down
12 changes: 12 additions & 0 deletions components/lib/splitter/__snapshots__/Splitter.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ exports[`Splitter Nested 1`] = `
>
<div
class="p-splitter-panel flex align-items-center justify-content-center"
role="presentation"
style="flex-basis: calc(20% - 4px);"
>
Panel 1
Expand All @@ -22,13 +23,15 @@ exports[`Splitter Nested 1`] = `
</div>
<div
class="p-splitter-panel p-splitter-panel-nested"
role="presentation"
style="flex-basis: calc(80% - 4px);"
>
<div
class="p-splitter p-component p-splitter-vertical"
>
<div
class="p-splitter-panel flex align-items-center justify-content-center"
role="presentation"
style="flex-basis: calc(15% - 4px);"
>
Panel 2
Expand All @@ -43,13 +46,15 @@ exports[`Splitter Nested 1`] = `
</div>
<div
class="p-splitter-panel p-splitter-panel-nested"
role="presentation"
style="flex-basis: calc(85% - 4px);"
>
<div
class="p-splitter p-component p-splitter-horizontal"
>
<div
class="p-splitter-panel flex align-items-center justify-content-center"
role="presentation"
style="flex-basis: calc(20% - 4px);"
>
Panel 3
Expand All @@ -64,6 +69,7 @@ exports[`Splitter Nested 1`] = `
</div>
<div
class="p-splitter-panel flex align-items-center justify-content-center"
role="presentation"
style="flex-basis: calc(80% - 4px);"
>
Panel 4
Expand All @@ -84,6 +90,7 @@ exports[`Splitter Single Panel with size 1`] = `
>
<div
class="p-splitter-panel"
role="presentation"
style="flex-basis: calc(5% - 0px);"
>
Panel 1
Expand All @@ -108,6 +115,7 @@ exports[`Splitter Single Panel without size 1`] = `
>
<div
class="p-splitter-panel"
role="presentation"
style="flex-basis: calc(100% - 0px);"
>
Panel 1
Expand All @@ -132,6 +140,7 @@ exports[`Splitter Splitter requires two SplitterPanel components to wrap. 1`] =
>
<div
class="p-splitter-panel flex align-items-center justify-content-center"
role="presentation"
style="flex-basis: calc(50% - 4px);"
>
Panel 1
Expand All @@ -146,6 +155,7 @@ exports[`Splitter Splitter requires two SplitterPanel components to wrap. 1`] =
</div>
<div
class="p-splitter-panel flex align-items-center justify-content-center"
role="presentation"
style="flex-basis: calc(50% - 4px);"
>
Panel 2
Expand All @@ -162,6 +172,7 @@ exports[`Splitter Vertical layout 1`] = `
>
<div
class="p-splitter-panel"
role="presentation"
style="flex-basis: calc(50% - 4px);"
>
Panel 1
Expand All @@ -176,6 +187,7 @@ exports[`Splitter Vertical layout 1`] = `
</div>
<div
class="p-splitter-panel"
role="presentation"
style="flex-basis: calc(50% - 4px);"
>
Panel 2
Expand Down
11 changes: 10 additions & 1 deletion pages/scrolltop/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,16 @@ const ScrollTopDemo = () => {
}
];

return <DocComponent title="React ScrollTop Component" header="ScrollTop" description="ScrollTop gets displayed when it gets into viewport and used to navigate back to the top of the page." componentDocs={docs} apiDocs={['ScrollTop']} ptDocs={ptDocs} />;
return (
<DocComponent
title="React ScrollTop Component"
header="ScrollTop"
description="ScrollTop gets displayed when it gets into viewport and used to navigate back to the top of the page."
componentDocs={docs}
apiDocs={['ScrollTop']}
ptDocs={ptDocs}
/>
);
};

export default ScrollTopDemo;

0 comments on commit deef231

Please sign in to comment.