From 63ac1276bc7dd882d1ed2b681886e5346116aa09 Mon Sep 17 00:00:00 2001 From: melloware Date: Thu, 30 Nov 2023 17:41:17 -0500 Subject: [PATCH] Fix #5461: Passthrough case insensitve props --- components/lib/componentbase/ComponentBase.js | 13 ++++++++----- components/lib/passthrough/tailwind/index.js | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/components/lib/componentbase/ComponentBase.js b/components/lib/componentbase/ComponentBase.js index 8960da8bcd..d4baf9aac7 100644 --- a/components/lib/componentbase/ComponentBase.js +++ b/components/lib/componentbase/ComponentBase.js @@ -497,13 +497,16 @@ export const ComponentBase = { obj = obj.pt; } + let fkey = 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(fkey) && !!params[fkey.split('.')[0]]; + const isTransition = fkey === 'transition' || (/./g.test(fkey) && !!(fkey.split('.')[1] === 'transition')); const datasetPrefix = 'data-pc-'; - const fkey = isNestedParam ? ObjectUtils.toFlatCase(key.split('.')[1]) : ObjectUtils.toFlatCase(key); + + fkey = isNestedParam ? ObjectUtils.toFlatCase(fkey.split('.')[1]) : fkey; const getHostInstance = (params) => { return params?.props ? (params.hostName ? (params.props.__TYPE === params.hostName ? params.props : getHostInstance(params.parent)) : params.parent) : undefined; @@ -523,8 +526,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, fkey, params) : _useDefaultPT(getPTClassValue, fkey, params)) : undefined; + const self = isNestedParam ? undefined : _usePT(_getPT(obj, componentName), getPTClassValue, fkey, params, componentName); const datasetProps = !isTransition && { ...(fkey === 'root' && { [`${datasetPrefix}name`]: params.props && params.props.__parentMetadata ? ObjectUtils.toFlatCase(params.props.__TYPE) : componentName }), diff --git a/components/lib/passthrough/tailwind/index.js b/components/lib/passthrough/tailwind/index.js index 41fcbe629f..87b8a7f1ec 100644 --- a/components/lib/passthrough/tailwind/index.js +++ b/components/lib/passthrough/tailwind/index.js @@ -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 } ) }),