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

fix(module:textarea): fix style string format and auto-size issues #2001

Merged
merged 16 commits into from
Oct 29, 2021

Conversation

anranruye
Copy link
Member

@anranruye anranruye commented Oct 5, 2021

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • Component style update
  • Bundle size optimization
  • Performance optimization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

🔗 Related issue link

Fixes #1997
Fixes #1998

💡 Background and solution

AutoSize doesn't work when:

  1. Change value by code
  2. Change TextArea width(eg. TextArea width is changed with the window resize)
  3. TextArea has a initial value

📝 Changelog

Language Changelog
🇺🇸 English fix style string format; fix auto-size issues
🇨🇳 Chinese

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Changelog is provided or not needed

@github-actions
Copy link

github-actions bot commented Oct 5, 2021

@codecov
Copy link

codecov bot commented Oct 5, 2021

Codecov Report

Merging #2001 (acf3402) into master (e698e40) will increase coverage by 2.03%.
The diff coverage is 55.38%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2001      +/-   ##
==========================================
+ Coverage   27.57%   29.60%   +2.03%     
==========================================
  Files         489      512      +23     
  Lines       32243    24612    -7631     
  Branches        0      240     +240     
==========================================
- Hits         8890     7287    -1603     
+ Misses      23353    17289    -6064     
- Partials        0       36      +36     
Impacted Files Coverage Δ
components/core/Base/AntDomComponentBase.cs 96.15% <ø> (+4.48%) ⬆️
components/core/JsInterop/JSInteropConstants.cs 29.31% <0.00%> (-0.52%) ⬇️
...s/core/JsInterop/modules/components/inputHelper.ts 0.00% <0.00%> (ø)
components/core/JsInterop/modules/styleHelper.ts 4.54% <0.00%> (ø)
components/input/TextArea.razor.cs 74.28% <73.52%> (-6.29%) ⬇️
components/input/TextArea.razor 94.44% <100.00%> (+9.07%) ⬆️
components/core/Helpers/MemberPath/PathNode.cs 46.15% <0.00%> (-8.85%) ⬇️
components/core/Reflection/TypeDefined.cs 77.77% <0.00%> (-7.94%) ⬇️
components/input/InputGroup.razor.cs 87.50% <0.00%> (-6.95%) ⬇️
components/tabs/TabPane.razor 86.66% <0.00%> (-6.20%) ⬇️
... and 428 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e698e40...acf3402. Read the comment docs.

@anranruye anranruye deleted the branch ant-design-blazor:master October 5, 2021 07:41
@anranruye anranruye closed this Oct 5, 2021
@anranruye anranruye deleted the master branch October 5, 2021 07:41
@anddrzejb
Copy link
Member

What happened here? It looked like a legitimate fix. You found some more issues with this?

@anranruye anranruye restored the master branch October 6, 2021 01:37
@anranruye anranruye deleted the master branch October 6, 2021 01:37
@anranruye anranruye restored the master branch October 6, 2021 01:40
@anranruye
Copy link
Member Author

anranruye commented Oct 6, 2021

@anddrzejb No, there is no more issue. I just wrongly made the changes on my default branch but not a new branch.

@anranruye anranruye reopened this Oct 6, 2021
@anranruye anranruye changed the title fix(module:textarea): fix style string format fix(module:textarea): fix style string format and auto-size issues Oct 6, 2021
@anranruye anranruye marked this pull request as draft October 7, 2021 17:00
@anranruye anranruye marked this pull request as ready for review October 8, 2021 15:49

protected override async Task OnAfterRenderAsync(bool firstRender)
{
await base.OnAfterRenderAsync(firstRender);
Copy link
Member

Choose a reason for hiding this comment

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

We need to call JS after firstRender.

Copy link
Member Author

@anranruye anranruye Oct 11, 2021

Choose a reason for hiding this comment

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

js is called in OnFirstAfterRenderAsync method.

site/AntDesign.Docs/Demos/Components/Input/demo/Area.md Outdated Show resolved Hide resolved
@@ -5,7 +5,7 @@
Dictionary<string, object> attributes =
new Dictionary<string, object>()
{
{ "onchange", CallbackFactory.Create(this, OnChangeAsync) },
{ "onchange", EventUtil.AsNonRenderingEventHandler<ChangeEventArgs>(e => OnChangeAsync(e)) },
Copy link
Member

Choose a reason for hiding this comment

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

I am sorry, I might not have been clear enough...to avoid unnecessary re-renderings, you actually have to change all of them:

          { "onchange", EventUtil.AsNonRenderingEventHandler<ChangeEventArgs>(e => OnChangeAsync(e)) },
            { "onblur", EventUtil.AsNonRenderingEventHandler<FocusEventArgs>(e => OnBlurAsync(e)) },
            { "oninput", EventUtil.AsNonRenderingEventHandler<ChangeEventArgs>(e => OnInputAsync(e)) },
            { "onkeypress", EventUtil.AsNonRenderingEventHandler<KeyboardEventArgs>(e => OnKeyPressAsync(e)) },
            { "onkeyup", EventUtil.AsNonRenderingEventHandler<KeyboardEventArgs>(e => OnKeyUpAsync(e)) },
            { "onkeydown", EventUtil.AsNonRenderingEventHandler<KeyboardEventArgs>(e => OnkeyDownAsync(e)) },
            { "onfocus", EventUtil.AsNonRenderingEventHandler<FocusEventArgs>(e => OnFocusAsync(e)) },

You can just copy-paste, this is what I was using in my tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

There is something wrong with the no value-binding scenario. So I had to add the event callbacks again.
With event callbacks:
动画1
With NonRenderingEventHandlers:
动画2

razor code:

<TextArea Placeholder="Autosize height based on content lines" AutoSize="true" />

I think we can do more reasearch later and apply this change in another pr.

Copy link
Member

@anddrzejb anddrzejb left a comment

Choose a reason for hiding this comment

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

LGTM

@ElderJames
Copy link
Member

Some tests was failed.

@anddrzejb
Copy link
Member

From the look of it, the tests:

  • TextArea_MaxRows_will_take_precedence_over_Rows()
  • TextArea_MinRows_creates_with_expected_height()
  • TextArea_Rows_creates_with_expected_height()

should probably be removed or moved to ts tests, since all these are testing is now done in js.

  • TextArea_ShowCount_increase() - this is a simple one. Add cut.Render() after cut.Find("textarea").KeyUp(String.Empty) and it will pass.

@ElderJames ElderJames merged commit f54ae99 into ant-design-blazor:master Oct 29, 2021
@anranruye anranruye deleted the master branch October 29, 2021 13:20
ElderJames added a commit that referenced this pull request Apr 23, 2022
…2001)

* fix(module:textarea): fix style string format

* seprate inner and outer style

* fix AutoSize

* fix custom style

* Update site/AntDesign.Docs/Demos/Components/Input/demo/Area.md

Co-authored-by: James Yeung <shunjiey@hotmail.com>

* Move SetStyle to styleHelper

* Update TextArea.razor

* Update TextArea.cs

* fix unit test

Co-authored-by: James Yeung <shunjiey@hotmail.com>
ElderJames added a commit that referenced this pull request Apr 30, 2022
…2001)

* fix(module:textarea): fix style string format

* seprate inner and outer style

* fix AutoSize

* fix custom style

* Update site/AntDesign.Docs/Demos/Components/Input/demo/Area.md

Co-authored-by: James Yeung <shunjiey@hotmail.com>

* Move SetStyle to styleHelper

* Update TextArea.razor

* Update TextArea.cs

* fix unit test

Co-authored-by: James Yeung <shunjiey@hotmail.com>
ElderJames added a commit that referenced this pull request Sep 6, 2022
…2001)

* fix(module:textarea): fix style string format

* seprate inner and outer style

* fix AutoSize

* fix custom style

* Update site/AntDesign.Docs/Demos/Components/Input/demo/Area.md

Co-authored-by: James Yeung <shunjiey@hotmail.com>

* Move SetStyle to styleHelper

* Update TextArea.razor

* Update TextArea.cs

* fix unit test

Co-authored-by: James Yeung <shunjiey@hotmail.com>
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.

Autosize height based on content lines not work by first render Not valid height css property in TextArea
3 participants