Skip to content
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

Let teachingtip treat placement logically not physically #3165

Merged

Conversation

marcelwgn
Copy link
Collaborator

Description

Every piece of code inside TeachingTip that handled the placement just took the values as is. I've added a function that returns the placementmode we want based on the flowdirection.

Motivation and Context

Closes #458

How Has This Been Tested?

Tested manually since the existing placement mode tests failed even if I just build master branch without any changes.

Screenshots (if appropriate):

@msft-github-bot msft-github-bot added the needs-triage Issue needs to be triaged by the area owners label Aug 20, 2020
@@ -1343,6 +1343,47 @@ void TeachingTip::ClosePopup()
}
}

winrt::TeachingTipPlacementMode TeachingTip::GetFlowDirectionAdjustedPlacement(const winrt::TeachingTipPlacementMode& placementMode)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetFlowDirectionAdjustedPlacement [](start = 45, length = 33)

@jevansaks do you remember why we didn't do this for the initial check in? I know that we talked about it but I can't recall what we got hung up on.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, unfortunately I don't remember either.

@StephenLPeters
Copy link
Contributor

How confident are you in your manual testing. I think I remember this being more complicated than we thought.

@StephenLPeters
Copy link
Contributor

We should add a test which sets the flow direction to rtl

@ranjeshj ranjeshj added team-Controls Issue for the Controls team area-TeachingTip and removed needs-triage Issue needs to be triaged by the area owners labels Aug 21, 2020
@marcelwgn
Copy link
Collaborator Author

I've added a test now which should test this quite thoroughly. My confidence in the manual tests I did jumped off a clip when I saw how many mistakes the TeachingTip "made" in the test. Should be good now though.

@@ -350,6 +350,8 @@ public void SpecifiedPlacement()
var targetRect = GetTargetBounds();

// All positions are valid
// The following might not always work, so repeat.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// The following might not always work, so repeat. [](start = 20, length = 50)

Really? what happens? was that the case before this change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not entirely sure what the root cause is, however when running those tests locally, I noticed that the rect (and the red border we use to show it) don't always show up. The problem is that this leaves the TeachingTip to believe it has more space and fails the test.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why wasn't this causing the test to fail before this change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test was very unreliable on my machine before that change, only 20% of the time it actually ran through.

ScrollTargetIntoView();
ScrollBy(10);

new CheckBox(FindElement.ByName("PageRTLCheckbox")).Check();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FindElement [](start = 33, length = 11)

Teaching Tip's test page uses the TeachingTipTestPageElements class to get things like this, I'd prefer that this get moved there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#Fixed

SetPreferredPlacement(PlacementOptions.Center);
VerifyPlacement("Center");

new CheckBox(FindElement.ByName("PageRTLCheckbox")).Uncheck();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FindElement [](start = 33, length = 11)

same here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#Fixed

return winrt::TeachingTipPlacementMode::Center;
}
}
return winrt::TeachingTipPlacementMode::Auto;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeachingTipPlacementMode [](start = 18, length = 24)

Is this needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either this or a default cause for our switch case, otherwise not all code paths would return a value according to the compiler.

@StephenLPeters
Copy link
Contributor

Since flow direction is not app wide but rather a propogating property. What happens if the teaching tip is LeftToRight but its target is RightToLeft? Like what would happen if you defined your teaching tip in you App.Resources and its target was in an RTL Panel. Does it maybe make more sense for the positioning logic use the flowLayout of the target where the content of the teaching tip would use the tip's flow layout?

@StephenLPeters
Copy link
Contributor

Since flow direction is not app wide but rather a propogating property. What happens if the teaching tip is LeftToRight but its target is RightToLeft? Like what would happen if you defined your teaching tip in you App.Resources and its target was in an RTL Panel. Does it maybe make more sense for the positioning logic use the flowLayout of the target where the content of the teaching tip would use the tip's flow layout?

@ranjeshj curious what you think.

@marcelwgn
Copy link
Collaborator Author

Since flow direction is not app wide but rather a propogating property. What happens if the teaching tip is LeftToRight but its target is RightToLeft? Like what would happen if you defined your teaching tip in you App.Resources and its target was in an RTL Panel. Does it maybe make more sense for the positioning logic use the flowLayout of the target where the content of the teaching tip would use the tip's flow layout?

That's a very good point. Maybe, reacting based on the target (if it exists) is actually the better idea. However I am not sure how common it is for a Page or part of an app to have a different flowdirection then the rest of the app. I think the main reason why we need to support RTL is for users who use RTL languages resulting in all apps being in RTL. In that case, it shouldn't really matter if we use the targets direction or the TeachingTips one.

@ranjeshj
Copy link
Contributor

ranjeshj commented Sep 1, 2020

Since flow direction is not app wide but rather a propogating property. What happens if the teaching tip is LeftToRight but its target is RightToLeft? Like what would happen if you defined your teaching tip in you App.Resources and its target was in an RTL Panel. Does it maybe make more sense for the positioning logic use the flowLayout of the target where the content of the teaching tip would use the tip's flow layout?

That's a very good point. Maybe, reacting based on the target (if it exists) is actually the better idea. However I am not sure how common it is for a Page or part of an app to have a different flowdirection then the rest of the app. I think the main reason why we need to support RTL is for users who use RTL languages resulting in all apps being in RTL. In that case, it shouldn't really matter if we use the targets direction or the TeachingTips one.

Not entirely sure. Adding @MikeHillberg and @YuliKl. How do we deal with this in a popup ?

@StephenLPeters
Copy link
Contributor

I agree that most of the time the flow direction of the target and the tip will be the same. The question is what is the right behavior when they aren't.

@StephenLPeters
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@StephenLPeters StephenLPeters merged commit a560a86 into microsoft:master Sep 24, 2020
@ghost
Copy link

ghost commented Oct 28, 2020

🎉Microsoft.UI.Xaml v2.5.0-prerelease.201027002 has been released which incorporates this pull request.:tada:

Handy links:

@ghost
Copy link

ghost commented Nov 5, 2020

🎉Microsoft.UI.Xaml v2.5.0-prerelease.201027002 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-TeachingTip team-Controls Issue for the Controls team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TeachingTip in RTL treats Placement=Left as physical instead of logical
5 participants