-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(popup): Remove containerElement prop from Popper #1524
Changes from 4 commits
2878689
c48c194
e97fbc2
17c8674
a1e50b5
097459b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import {API, FileInfo, Options, JSXElement} from 'jscodeshift'; | ||
import {getImportRenameMap} from './utils/getImportRenameMap'; | ||
import {hasImportSpecifiers} from '../v6/utils'; | ||
|
||
const popupBarPackage = '@workday/canvas-kit-react/popup'; | ||
|
||
export default function transformer(file: FileInfo, api: API, options: Options) { | ||
const j = api.jscodeshift; | ||
|
||
const root = j(file.source); | ||
|
||
if (!hasImportSpecifiers(api, root, popupBarPackage, ['Popper'])) { | ||
return file.source; | ||
} | ||
|
||
const {importMap, styledMap} = getImportRenameMap(j, root, popupBarPackage); | ||
|
||
root | ||
.find( | ||
j.JSXElement, | ||
(value: JSXElement) => | ||
value.openingElement.name.type === 'JSXIdentifier' && | ||
(value.openingElement.name.name === importMap.Popper || | ||
value.openingElement.name.name === styledMap.Popper) | ||
) | ||
.forEach(nodePath => { | ||
const attributes = nodePath.value.openingElement.attributes; | ||
// Remove containerElement prop from Popper component | ||
if (attributes) { | ||
nodePath.value.openingElement.attributes = attributes.filter(item => | ||
item.type === 'JSXAttribute' && | ||
item.name.type === 'JSXIdentifier' && | ||
['containerElement'].includes(item.name.name) | ||
? false | ||
: true | ||
); | ||
} | ||
}); | ||
|
||
return root.toSource(); | ||
} | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import {expectTransformFactory} from './expectTransformFactory'; | ||
import transform from '../removePropFromPopper'; | ||
import {stripIndent} from 'common-tags'; | ||
|
||
const expectTransform = expectTransformFactory(transform); | ||
|
||
describe('removePropFromPopper', () => { | ||
it('should remove containerElement prop from Popper component', () => { | ||
const input = stripIndent` | ||
import {Popper} from '@workday/canvas-kit-react/popup'; | ||
|
||
<Popper containerElement="any element here" /> | ||
`; | ||
|
||
const expected = stripIndent` | ||
import {Popper} from '@workday/canvas-kit-react/popup'; | ||
|
||
<Popper /> | ||
`; | ||
|
||
expectTransform(input, expected); | ||
}); | ||
|
||
it('should remove containerElement prop from Popper component imported from main package', () => { | ||
const input = stripIndent` | ||
import {Popper} from '@workday/canvas-kit-react'; | ||
|
||
<Popper containerElement="any element here" /> | ||
`; | ||
|
||
const expected = stripIndent` | ||
import {Popper} from '@workday/canvas-kit-react'; | ||
|
||
<Popper /> | ||
`; | ||
|
||
expectTransform(input, expected); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,9 @@ any questions about the update. | |
- [Icons](#icons) | ||
- [ActionBar Component Updates](#actionbar-component-updates) | ||
- [Status Indicator Width](#status-indicator-width) | ||
- [Popup Cards](popup-cards) | ||
- [Popup Cards](#popup-cards) | ||
- [Popper Props Update](#popper-props-update) | ||
- [Component Promotions](#component-promotion) | ||
|
||
## Codemod | ||
|
||
|
@@ -463,6 +465,11 @@ If your code contains any hacks to make a `Modal` overflow, these hacks should n | |
`max-height` of the `Modal.Body` element using calculations. These should be removed. The | ||
`Popup.Card` now has a max height and the `Popup.Body` height is automatically calculated. | ||
|
||
## Popper Props Update | ||
|
||
We removed the `containerElement` prop from Popper component because it's no longer needed with | ||
Fullscreen API. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we have a codemod for this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've checked usage of Popper, so it will be good to add codemod for making migration easier. Thanks for catching it, I'll add it |
||
|
||
## Component Promotions | ||
|
||
After some [assessment](https://github.com/Workday/canvas-kit/issues/1395) we've decided to promote | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for adding this!