Skip to content

Commit

Permalink
Fix primefaces#5461: Passthrough case insensitve props
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Jan 9, 2024
1 parent c1007f3 commit 710c5f3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
12 changes: 6 additions & 6 deletions components/lib/componentbase/ComponentBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -497,13 +497,13 @@ export const ComponentBase = {
obj = obj.pt;
}

const originalkey = ObjectUtils.toFlatCase(key);
const hostName = params.hostName && ObjectUtils.toFlatCase(params.hostName);
const componentName = hostName || (params.props && params.props.__TYPE && ObjectUtils.toFlatCase(params.props.__TYPE)) || '';
const isNestedParam = /./g.test(key) && !!params[key.split('.')[0]];
const isTransition = key === 'transition' || (/./g.test(key) && !!(key.split('.')[1] === 'transition'));

const isNestedParam = /./g.test(originalkey) && !!params[originalkey.split('.')[0]];
const isTransition = fkey === 'transition' || (/./g.test(originalkey) && !!(originalkey.split('.')[1] === 'transition'));
const datasetPrefix = 'data-pc-';
const fkey = isNestedParam ? ObjectUtils.toFlatCase(key.split('.')[1]) : ObjectUtils.toFlatCase(key);
const fkey = isNestedParam ? ObjectUtils.toFlatCase(originalkey.split('.')[1]) : originalkey;

const getHostInstance = (params) => {
return params?.props ? (params.hostName ? (params.props.__TYPE === params.hostName ? params.props : getHostInstance(params.parent)) : params.parent) : undefined;
Expand All @@ -523,8 +523,8 @@ export const ComponentBase = {
return ObjectUtils.isString(value) ? { className: value } : value;
};

const globalPT = searchInDefaultPT ? (isNestedParam ? _useGlobalPT(getPTClassValue, key, params) : _useDefaultPT(getPTClassValue, key, params)) : undefined;
const self = isNestedParam ? undefined : _usePT(_getPT(obj, componentName), getPTClassValue, key, params, componentName);
const globalPT = searchInDefaultPT ? (isNestedParam ? _useGlobalPT(getPTClassValue, originalkey, params) : _useDefaultPT(getPTClassValue, originalkey, params)) : undefined;
const self = isNestedParam ? undefined : _usePT(_getPT(obj, componentName), getPTClassValue, originalkey, params, componentName);

const datasetProps = !isTransition && {
...(fkey === 'root' && { [`${datasetPrefix}name`]: params.props && params.props.__parentMetadata ? ObjectUtils.toFlatCase(params.props.__TYPE) : componentName }),
Expand Down
9 changes: 7 additions & 2 deletions components/lib/confirmdialog/confirmdialog.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ import { DialogProps } from '../dialog';
import { PassThroughOptions } from '../passthrough';
import { IconType, PassThroughType } from '../utils';

export declare type ConfirmDialogPassThroughType<T> = PassThroughType<T, ConfirmDialogThroughMethodOptions>;
export declare type ConfirmDialogPassThroughType<T> = PassThroughType<T, ConfirmDialogPassThroughMethodOptions>;
export declare type ConfirmDialogPassThroughTransitionType = ReactCSSTransitionProps | ((options: ConfirmDialogPassThroughMethodOptions) => ReactCSSTransitionProps) | undefined;

/**
* Custom passthrough(pt) option method.
*/
export interface ConfirmDialogThroughMethodOptions {
export interface ConfirmDialogPassThroughMethodOptions {
props: ConfirmDialogProps;
state: ConfirmDialogState;
}
Expand Down Expand Up @@ -84,6 +85,10 @@ export interface ConfirmDialogPassThroughOptions {
* @see {@link ComponentHooks}
*/
hooks?: ComponentHooks;
/**
* Used to control React Transition API.
*/
transition?: ConfirmDialogPassThroughTransitionType;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion components/lib/passthrough/tailwind/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ const Tailwind = {
'cursor-default': props.readOnly
},
{
'outline-none outline-offset-0 shadow-[0_0_0_0.2rem_rgba(191,219,254,1)] dark:shadow-[0_0_0_0.2rem_rgba(147,197,253,0.5)]': context.focused
'outline-none outline-offset-0 shadow-[0_0_0_0.2rem_rgba(191,219,254,1)] dark:shadow-[0_0_0_0.2rem_rgba(147,197,253,0.5)]': context.active
}
)
}),
Expand Down

0 comments on commit 710c5f3

Please sign in to comment.