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:select): Select with group refresh on datasource change #2048

Merged
merged 6 commits into from
Oct 29, 2021

Conversation

anddrzejb
Copy link
Member

@anddrzejb anddrzejb commented Oct 20, 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 #2031

💡 Background and solution

There were 2 issues here, both originating form the fact that the consumer was setting the DataSource from the consuming component's OnAfterRender lifecycle method.

  1. First issue, the exception, was because the SelectOptionItems were loaded with items after rendering. So items did not have any ElementReference set. When user was clicking on the Select, the method was called to scroll to either selected or first element in the list. But because there was no ElementRefernece set yet, the framework was throwing the NullReferenceException. My approach here was to check if ElementRefernece.Id is null. If it is, call StateHasChanged().
  2. Second issue appeared after fixing the first issue - the dropdown was empty. I tracked it to CascadingValue having Fixed set. So when the DataSource changed, the SelectOptionGroup was never informed and never re-rendered the list.

I also fixed 2 tests that would fail once we move to net6.

📝 Changelog

Language Changelog
🇺🇸 English
🇨🇳 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 20, 2021

Prepare preview

@codecov
Copy link

codecov bot commented Oct 20, 2021

Codecov Report

Merging #2048 (c7d3fd1) into master (46e2fc6) will increase coverage by 1.85%.
The diff coverage is 60.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2048      +/-   ##
==========================================
+ Coverage   25.76%   27.62%   +1.85%     
==========================================
  Files         489      512      +23     
  Lines       32243    24574    -7669     
  Branches        0      238     +238     
==========================================
- Hits         8309     6788    -1521     
+ Misses      23934    17750    -6184     
- Partials        0       36      +36     
Impacted Files Coverage Δ
components/select/Select.razor 87.50% <ø> (+7.50%) ⬆️
components/select/Select.razor.cs 49.52% <50.00%> (+2.63%) ⬆️
components/select/SelectBase.cs 64.01% <50.00%> (+7.01%) ⬆️
components/select/internal/SelectOptionItem.cs 82.35% <100.00%> (+2.55%) ⬆️
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%) ⬇️
...ponents/date-picker/types/DatePickerPlaceholder.cs 22.72% <0.00%> (-4.20%) ⬇️
components/input/TextArea.razor.cs 77.52% <0.00%> (-3.05%) ⬇️
... and 426 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 46e2fc6...c7d3fd1. Read the comment docs.

@ElderJames ElderJames merged commit 92d5c0d into ant-design-blazor:master Oct 29, 2021
@anddrzejb anddrzejb deleted the selectWithGroup branch October 30, 2021 08:46
ElderJames pushed a commit that referenced this pull request Apr 23, 2022
…2048)

* test: fix net6 tests

* fix(module:select): group refresh on option change
ElderJames pushed a commit that referenced this pull request Apr 30, 2022
…2048)

* test: fix net6 tests

* fix(module:select): group refresh on option change
ElderJames pushed a commit that referenced this pull request Sep 6, 2022
…2048)

* test: fix net6 tests

* fix(module:select): group refresh on option change
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.

An error occurred while using <Select> with grouping (GroupName).
2 participants