Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(dropdown): react - dont pass hidden prop to cds-dropdown when false
Fixes #151 passing in a false value renders hidden="false" in the DOM, which is breaking the overlay layer logic This is the boolean attribute issue that also effected modals as well
- Loading branch information
1 parent
7a69762
commit 41198b3
Showing
9 changed files
with
14,578 additions
and
80 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (c) 2016-2022 VMware, Inc. All Rights Reserved. | ||
* This software is released under MIT license. | ||
* The full license information can be found in LICENSE in the root directory of this project. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
export function logReactVersion(react: { version: string }) { | ||
if (window && (window as any).CDS && !(window as any).CDS._react.version) { | ||
(window as any).CDS._react.version = react.version; | ||
} | ||
} | ||
|
||
/** | ||
* Converts a false value for `hidden` to `undefined` so it doesn't get rendered in the DOM | ||
* | ||
* There is an open issue where lit/react passes the false value to the element in the dom | ||
* this isn't valid per the spec for boolean attributes. | ||
* | ||
* We mostly work around it with CSS, but it's still causing some problems with the modal overlay | ||
* REMOVE THIS WHEN THE FOLLOWING ISSUE IS RESOLVED (also remove all of the CSS fixes) | ||
* | ||
* https://github.com/lit/lit/issues/3053 | ||
* @param Component | ||
* @returns Component | ||
*/ | ||
export function removeFalseHiddenProp<P extends { hidden?: boolean }>(Component: React.ComponentType<P>) { | ||
return (props: P) => { | ||
const { hidden } = props; | ||
return <Component {...(props as P)} hidden={hidden ? true : undefined} />; | ||
}; | ||
} |