Conversation
072460a to
136934e
Compare
Codecov Report
@@ Coverage Diff @@
## master #1358 +/- ##
==========================================
+ Coverage 72.93% 72.99% +0.05%
==========================================
Files 775 776 +1
Lines 5823 5828 +5
Branches 1698 1706 +8
==========================================
+ Hits 4247 4254 +7
+ Misses 1570 1568 -2
Partials 6 6
Continue to review full report at Codecov.
|
|
@Bugaa92 can you please link issue in |
|
We should:
|
agreed
agreed
shouldn't we rather avoid using
I checked, but how can we ensure that programmatically? |
9564fcf to
1dd5574
Compare
We can, but we don't export
If we will remove the package 😼 |
Should we try that? I'd do it, but not sure how. Do we want it?
exactly my point :) |
| /** | ||
| * Popper relies on the 3rd party library [Popper.js](https://github.com/FezVrasta/popper.js) for positioning. | ||
| */ | ||
| const Popper: React.FunctionComponent<PopperProps> = props => { |
There was a problem hiding this comment.
TBH I didn't really now HOW to test it. Reasons:
PopperJSis setting styles directly on element so we have no control and no ability to predict anything there- We could test returned
placementbut that's basically the result ofgetPlacementmethod that is already tested
Unless you want to test the options arguments we pass to PopperJS and mock the constructor? Open to suggestions.
packages/react/src/themes/teams/components/Popup/popupContentStyles.ts
Outdated
Show resolved
Hide resolved
|
not sure why breaking change in the I would suggest to leave this change aside from the PR, as it is not necessary to solve the PR's goal |
It's not really necessary, but I find the existing I believe the new API is more discoverable by users and more clear in what it's trying to accomplish.
Here's working code achieving the same scenario with function and class components. Doesn't really look like tricky stuff to me: import * as React from 'react'
import { Button, Popup, Segment, Loader, Grid, Header } from '@stardust-ui/react'
const CustomSegment = () => (
<Segment styles={{ minHeight: '300px' }}>Hello from loaded data!</Segment>
)
const AsyncDataLoader = props => {
const [data, setData] = React.useState(<Loader />)
React.useEffect(() => {
setTimeout(() => {
setData(<CustomSegment />)
props.onLoaded()
}, 1000)
}, [])
return data
}
const PopupExampleAsyncFn = () => {
const [loading, setLoading] = React.useState(true)
return (
<Popup
onOpenChange={(e, data) => {
if (!data.open) setLoading(true)
}}
trigger={<Button icon="expand" content="Click me!" />}
positioningDependencies={[loading]}
content={{ content: <AsyncDataLoader onLoaded={() => setLoading(false)} /> }}
/>
)
}
class PopupExampleAsyncClass extends React.Component {
state = { loading: true }
render() {
return (
<Popup
onOpenChange={(e, data) => {
if (!data.open) this.setState({ loading: true })
}}
trigger={<Button icon="expand" content="Click me!" />}
positioningDependencies={[this.state.loading]}
content={{
content: <AsyncDataLoader onLoaded={() => this.setState({ loading: false })} />,
}}
/>
)
}
}
const PopupExampleAsync = () => (
<Grid columns={2}>
<Header as="h3" content="PopupExampleAsyncFn" />
<PopupExampleAsyncFn />
<Header as="h3" content="PopupExampleAsyncClass" />
<PopupExampleAsyncClass />
</Grid>
)
export default PopupExampleAsync
Hard to claim that without any user feedback. I checked some of our user's code and this API is not used at all.. Personally I had difficulties understanding how the However, I don't feel too strongly about this and I am willing to hear other thoughts. I can agree to having this discussion on another PR. @layershifter , what do you think? |
89384fa to
ca29e74
Compare
Changed dependencies in
Generated by 🚫 dangerJS |
There was a problem hiding this comment.
nit: lets rename it to pointerTarget (and corresponding pointingTargetRefElement). Otherwise from the code it was unclear whether this implies element that is pointer itself (like arrow), or its target, or something else
There was a problem hiding this comment.
but pointerRef is more aligned to current targetRef:
/**
* Ref object containing the pointer node.
*/
pointerRef?: React.RefObject<Element>
/**
* Ref object containing the target node (the element that we're using as reference for Popper box).
*/
targetRef?: React.RefObject<Element>To me it seems that having pointerTarget and targetRef is more confusing
a714c72 to
5306c46
Compare
There was a problem hiding this comment.
I tried updating to:
import * as PopperJS from 'popper.js'If I change the constructor to new PopperJS.default I get a lint error that constructor cannot be lowercase and the code transpiled to CommonJS will result in the same error.
Are the types wrong? I'm blocked with this right now...
@layershifter @kuzhelov
There was a problem hiding this comment.
have checked popper.js module used in Stardust, as well as tried to repro the issue in Stardust environment - seems that everything is working fine, as well as types are properly defined for PopperJS module. Maybe this is a problem with client environment setup, where there is a stable repro for that - lets unblock this PR and see.
5306c46 to
3893eb8
Compare


feat(popper): custom react wrapper
Problem description
Fixes #1342
We need to build a custom React wrapper around popper.js library (pure JS). The one offered by popper.js, called react-popper has performance issues: Performance issues on a large number of poppers #185:
React Bootstrap and Material UI are using
popper.jsas well and have decided to write their own React wrappers, https://material-ui.com/utils/popper/(see: floating-ui/react-popper#185 (comment))
Proposed solution
Create a basic custom
Poppercomponent (similar to the one provided byreact-popper) that: