Skip to content

Conversation

@michael-hawker
Copy link
Member

@michael-hawker michael-hawker commented Jun 3, 2020

Related #3289

  • Fix FontSize Styling Issue
    • Adds TryFindResource (from WPF) compatible function
    • UnitTest that?
  • Test out Rendering callback for layout issue
  • Started DOC PR HERE
  • Use existing Parent property instead of new Owner for TTBI read-only

PR Type

What kind of change does this PR introduce?

  • Bugfix

What is the current behavior?

Layout was incorrect when ASB had focus, and had no text, and added/removed token
FontSize had to be manually set

What is the new behavior?

We now toggle the visibility of the offending PlaceholderText ContentControl which resolves the issue for now.

Now we only set FontSize to our desired size if it's not overwritten by the developer. It can also be overridden by a style property.

image

I have my resource which the lower box icon is inheriting properly, the top example is overriding it with a local value.

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tested code with current supported SDKs
  • Pull Request has been submitted to the documentation repository instructions. Link:
  • Sample in sample app has been added / updated (for bug fixes / features)
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Header has been added to all new source files (run build/UpdateHeaders.bat)
  • Contains NO breaking changes

Other information

@ghost
Copy link

ghost commented Jun 3, 2020

Thanks michael-hawker for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌

@ghost ghost assigned Kyaa-dost Jun 3, 2020
@michael-hawker michael-hawker added this to the 6.1 milestone Jun 3, 2020
<Thickness x:Key="TokenizingTextBoxPresenterMargin">0,0,6,0</Thickness>
<x:Double x:Key="TokenizingTextBoxTokenSpacing">2</x:Double>
<Thickness x:Key="TextControlBorderThemeThicknessFocused">2</Thickness>
<x:Double x:Key="TokenizingTextBoxIconFontSize">16</x:Double>
Copy link
Member Author

Choose a reason for hiding this comment

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

This is actually ignored as we don't have a good way to access it from the code-behind of the templated control (another helper in the future?). I'm not sure if that's what the ComponentResourceKey was for in WPF (I never used that in my days there).

I can add a comment linking to the hard-coded value on line 110 below in TTB.ASB.cs.

@michael-hawker
Copy link
Member Author

Ugh, this might be breaking something when adding a token, investigating...

This was an issue with the PlaceholderText ContentControl in the AutoSuggestBox which would not update it's layout properly when the ASB had focus when we would add/remove a token.
Copy link
Contributor

@marcpems marcpems left a comment

Choose a reason for hiding this comment

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

LGTM, only minor comments

placeholder.Visibility = Visibility.Collapsed;

// After we ensure we've hid the control, make it visible again (this is inperceptable to the user).
_ = CompositionTargetHelper.ExecuteAfterCompositionRenderingAsync(() =>
Copy link
Contributor

Choose a reason for hiding this comment

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

nice!

{
if (current.Resources?.TryGetValue(resourceKey, out value) == true)
{
return value;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not keen on multiple return points from a function as it can make maintenance more tricky.
however this looks pretty simple and easy to read in this case.

/// <returns>Awaitable Task</returns>
public static Task<bool> ExecuteAfterCompositionRenderingAsync(Action action)
{
Guard.IsNotNull(action, nameof(action));
Copy link
Contributor

Choose a reason for hiding this comment

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

Could/should this just be a no-op (Task.CompletedTask) in this case? Do we want to throw?

/// </summary>
/// <param name="action">Action to be executed after render pass</param>
/// <returns>Awaitable Task</returns>
public static Task<bool> ExecuteAfterCompositionRenderingAsync(Action action)
Copy link
Contributor

Choose a reason for hiding this comment

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

I would like a Task based version (for the action parameter, Func) so the returned task from this method can await for the action to executed. Not sure its part of this PR, just something I noticed when I was reviewing this.

Copy link
Contributor

@Kyaa-dost Kyaa-dost left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍🚀🚀

@michael-hawker michael-hawker merged commit 8e099de into master Jun 4, 2020
@delete-merged-branch delete-merged-branch bot deleted the mhawker/ttb-updates branch June 4, 2020 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants