-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Popover fixes on tablet #7985
Popover fixes on tablet #7985
Conversation
…ection depending on screen size
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 the hard work on the PR @srdjanrist. Could you please help me understand the motive and your approach behind the changes you have done? There are a lot of images. Please use
to group them. Thanks. |
Looking into component Simply adding property |
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.
There are many lint errors. Please fix those. Are you following the contribution guidelines? Please run npm run lint
before pushing chnages.
I think the simplest way to do it would be to modify the Popover Component so that we do
<Modal
type={!props.isSidebarScreenWidth ? CONST.MODAL.MODAL_TYPE.POPOVER : CONST.MODAL.MODAL_TYPE.BOTTOM_DOCKED}
instead of passing fromSidebarMediumScreen
which is basically doing the same.
Also, this prop is not defined in the prop definitions. If there is a reason to keep it, please add prop-types for it in every component it is passed as a prop.
@@ -42,6 +42,7 @@ const AddPaymentMethodMenu = props => ( | |||
isVisible={props.isVisible} | |||
onClose={props.onClose} | |||
anchorPosition={props.anchorPosition} | |||
fromSidebarMediumScreen={!props.isSmallScreenWidth} |
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.
Why do you need to pass this when you have already added to BasePopoverMenu
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.
You are right. This will be removed.
onModalHide={this.onModalHide} | ||
anchorPosition={this.props.anchorPosition} | ||
fromSidebarMediumScreen={!this.props.isSmallScreenWidth} |
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.
How is this prop related to this menu? This menu opens from the composer ➕ .
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.
The menu for attachment picker opens from the same position as the one from the composer ➕.
src/styles/styles.js
Outdated
createPaymentMethodMenuContainer: { | ||
top: 380, | ||
}, |
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.
I don't see why do we need to pass the width now. If it was working fine on web without it.
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.
This is because let position = getClickedElementLocation(nativeEvent);
has native implementation which returns just { bottom: 0, left: 0 }
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.
Can't we use https://reactnative.dev/docs/0.64/pressevent to calculate the values?
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.
@parasharrajat Thanks for the docs.
Looking at the example:
{
changedTouches: [PressEvent],
identifier: 1,
locationX: 8,
locationY: 4.5,
pageX: 24,
pageY: 49.5,
target: 1127,
timestamp: 85131876.58868201,
touches: []
}
we could theoretically calculate the top left coordinate of the pressed component, by using pageX
, pageY
and locationX
, locationY
. We would still need to add a height value of the pressed component to y
coordinate, to move the popover to its bottom.
What do you think about that?
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.
Ok. I think that's fine if height is needed let's calculate it. But I don't think that is needed. Setting the top and left edges should be fine. the menu will always be rendered top-down so we should be good without height.
Yes. This could be done that way. Would you like this prop |
Wrapping with |
@@ -3,7 +3,7 @@ import React from 'react'; | |||
import {propTypes as popoverPropTypes, defaultProps} from './popoverPropTypes'; | |||
import CONST from '../../CONST'; | |||
import Modal from '../Modal'; | |||
import {windowDimensionsPropTypes} from '../withWindowDimensions'; | |||
import withWindowDimensions, {windowDimensionsPropTypes} from '../withWindowDimensions'; | |||
|
|||
const propTypes = { | |||
...(_.omit(popoverPropTypes, _.keys(windowDimensionsPropTypes))), |
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.
Needs correction now.
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.
Updated. I have left only that propTypes from popoverPropTypes without omitting windowDimensionsProps
return { | ||
bottom: 0, | ||
left: 0, | ||
bottom: nativeEvent.nativeEvent.pageY - nativeEvent.nativeEvent.locationY, |
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.
nativeEvent.nativeEvent
looks confusing.
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.
Agree. Based on previous handling of this, I have changed the code that calls this method to pass the nested nativeEvent
property instead of the whole object.
@@ -186,7 +186,10 @@ class AvatarWithImagePicker extends React.Component { | |||
: ( | |||
<DefaultAvatar /> | |||
)} | |||
<AttachmentPicker type={CONST.ATTACHMENT_PICKER_TYPE.IMAGE}> | |||
<AttachmentPicker | |||
anchorPosition={styles.createMenuPositionProfile} |
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.
anchorPosition={styles.createMenuPositionProfile} | |
anchorPosition={this.props.anchorPosition} |
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.
Updated
onModalHide={this.onModalHide} | ||
anchorPosition={this.props.anchorPosition} |
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.
Did you add the new prop definition?
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.
I have updated the prop definiton.
@parasharrajat Second video shows Android, and the animation is present. Is it not supposed to be there? |
The motive is to keep the same animation on all platforms. When Menu opens from bottom on Mobile native, the animation is differnt. But when they behave like a web on tablets. They should have same animations. cc: @Expensify/design |
I agree with that Rajat. |
Thanks for the input! |
src/components/Modal/BaseModal.js
Outdated
animationInTiming={this.props.disableAnimation ? 1 : this.props.animationInTiming} | ||
animationOutTiming={this.props.disableAnimation ? 1 : this.props.animationOutTiming} |
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.
Not happy with this change. Can't we just follow the same pattern as we do on the web?
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.
Updated the pull request with a recommended change. 😊
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.
The code looks fine. I will test it shortly.
Testing it. Finally fixed my Mac. |
Didn't complete my testing. I will finish it up tomorrow. |
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.
Hey @srdjanrist, we'll need to resolve the issue @parasharrajat mentioned, as it doesn't look ideal. I'm afraid I don't have any suggestions for you, but sharing the issue in the shared Slack channel might be a good idea. As it's quite possible that someone has faced and solved this problem before. |
I have consulted people on Slack, and will try their approach as well. I was thinking of another approach to this. |
That would be Overkill. Can't we use |
I will check this today. |
Updated MenuItem with code for measuring layout with the mentioned method |
const MenuItem = props => ( | ||
<Pressable | ||
onPress={(e) => { |
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.
This change is not acceptable. We don't have to touch the MenuItem for this. Instead, use the ref to calculate whatever is needed on the parent components that use it.
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.
Hi @srdjanrist, could you please address this comment so we can move forward :)
CLA Assistant Lite bot: I have read the CLA Document and I hereby sign the CLA 0 out of 2 committers have signed the CLA. |
Details
I have changed how popovers are shown on iPad medium and large devices. Since these are considered as native, sometimes popovers were shown bottom docked modals, instead of onscreen modals. Medium and large devices are considered as being "not-small" and this flag (of not being small) with a combination of native methods caused inconsistencies in different places that popovers are shown.
Fixed Issues
$ #7375
Tests
PR Review Checklist
Contributor (PR Author) Checklist
main
before submitting my PR for review### Fixed Issues
section abovesrc/languages/*
files (if applicable)Styling.md
) for all style edits I madePR Reviewer Checklist
main
before submitting the PR### Fixed Issues
section abovesrc/languages/*
files (if applicable)QA Steps
Tested On
Screenshots
Web
Mobile web
Desktop
iOS
iPad Narrow
iPad Wide
Android