-
-
Notifications
You must be signed in to change notification settings - Fork 999
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
feat(module:overlay): OverlayTrigger not bound to a div #937
feat(module:overlay): OverlayTrigger not bound to a div #937
Conversation
Codecov Report
@@ Coverage Diff @@
## master #937 +/- ##
=========================================
+ Coverage 5.69% 5.70% +0.01%
=========================================
Files 412 422 +10
Lines 22030 22271 +241
=========================================
+ Hits 1254 1270 +16
- Misses 20776 21001 +225
Continue to review full report at Codecov.
|
Thank you very much @anddrzejb , it help a lot. But if you implement a new component with a lot of repetitive code, it would increase maintenance costs and confuse users. We might be more comfortable with using a new template parameter:
However, I have to say that this is a great feature and I really hope to merge it into the project. |
I added this as a draft PR exactly for that purpose. I was hoping to get input on the idea and use others experience. Also, I did not want to spent a ton of time just to find out the solution is not acceptable. That is why I just did a code repeat - to get the discussion started as well as have a working example. To address your point - at first was trying to inherit from original component, but for the solution to work, |
@ElderJames following your suggestion, I did some research on multiple child elements and managed to revert to single component use. This seems to work. However there is still one (minor?) problem - I did not manage to replicate Edit: apparently I messed up merging with upstream. All significant changes are in commit 8c39956. The rest is merging with upstream and syncing with branch... |
Yes, a little bit of necessary JS is acceptable. |
@ElderJames now full functionality of |
@ElderJames I am now working on <Popover ContentTemplate="@_content" Title="Title">
<Unbound>
<Button type="primary" @ref="@context.Current">Hover me (unbound)</Button>
</Unbound>
</Popover> because I get a compilation error |
In the end of the post of ForwardRef, gave a solution for components. It may be:
|
That unfortunately does not work. I actually tried that when I was going through what is available in the base classes (sorry for not communicating that clearly). It may have something to do with the fact that |
Maybe we need to see how does MatBlazor do that. |
I will try to work it out. For now I've done |
Yes, we need to work on using |
Yes, Column's tooltip should switch to unbound usage and make it align center. |
@ElderJames I think that my last commit 59aebd2 concludes the works within the scope of this PR (I've got to admit it was more work than I planned, but quite fruitful). With this commit, I finally solved the issue I had with |
I think there are enough modifications to this pr that we can deal with it first. |
components/upload/Upload.razor
Outdated
<Tooltip Title="tips" Disabled="file.State != UploadState.Fail" Class="@containerClass" Style="@(IsPictureCard ? "" : "display: list-item;")"> | ||
@if (IsPictureCard && file.State == UploadState.Uploading) | ||
{ | ||
<div class="ant-upload-list-item ant-upload-list-item-uploading ant-upload-list-item-list-type-picture-card"> | ||
<div class="ant-upload-list-item-info"> | ||
<div class="ant-upload-list-item-thumbnail">@Locale.Uploading</div> | ||
<span class="ant-upload-list-item-name ant-upload-list-item-name-icon-count-1" title="@file.FileName"> | ||
@file.FileName | ||
</span> | ||
</div> | ||
<div class="ant-upload-list-item-progress"> | ||
<Progress Percent="file.Percent" StrokeWidth="2" Type="ProgressType.Line" ShowInfo="false"></Progress> | ||
<Unbound> |
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 find the Class
in Unbound usage is not work, and here is missing the containerClass
so the style is broken.
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.
That is absolutely correct. This is the situation when Tooltip
's div was actually used for something. Same situation as with Table
's Column
. I fixed it in the commit 9256ef1.
Finally we merged this PR, thanks a lot for this time! |
Thanks as well! I did not expect my attempt on making slider with tooltip will be so time consuming, but it was rewarding nevertheless. |
Yes, you've solved a big problem! |
* feat(module:overlay): OverlayTrigger not bound to a div * feat(module:overlay): OverlayTrigger not bound to a div * feat(module:overlay): Logic transfer to single Overlay * feat(module:overlay): remove obsolete duplication * feat(module:Tooltip): Add for unbounded oncontextmenu event handler * feat(module:tooltip): unbound js event listeners remove * docs(module:tooltip): unbound explanation * fix(module:button): attach Ref to top level html element @ref * feat(module:dropdown&tooltip&popconfirm&popover): Overlay not bound to a div * docs(module:dropdown&tooltip&popconfirm&popover): unbound explanation * feat(module:OverlayTrigger): common logic relocation * feat(module:overlaytrigger): Overlay not bound to a div * feat(module:DatePicker): Overlay not bound to a div * feat(module:select): Overlay not boud to div * fix(module:select): onclickarrow event relocation * fix(module:select): rename Show to OnArrowClick * feat(module:avatar): Overlay not bound to a div * docs(module:avatar): demo switch to unbound version * feat(module:autocomplete): partial OverlayTrigger not bound to a div * feat(module:slider): tooltip * docs(module:slider): tooltip * fix(module:overlay): add SetVisible method * feat: set Ref where missing, performance components register Ref when missing IsFixed flag for CascadeValue changed hard-code sequence numbers when using RenderTreeBuilder Rate component use Tooltip Unbound version Tabs test fix * fix: revert changes (accidental) * feat(module:upload): tooltip with unbound usage * feat(module:table): column use of unbound tooltip * feat(module:autocomplete):overlay unbound from div * fix(module:upload): missing div restore Co-authored-by: James Yeung <shunjiey@hotmail.com>
* feat(module:overlay): OverlayTrigger not bound to a div * feat(module:overlay): OverlayTrigger not bound to a div * feat(module:overlay): Logic transfer to single Overlay * feat(module:overlay): remove obsolete duplication * feat(module:Tooltip): Add for unbounded oncontextmenu event handler * feat(module:tooltip): unbound js event listeners remove * docs(module:tooltip): unbound explanation * fix(module:button): attach Ref to top level html element @ref * feat(module:dropdown&tooltip&popconfirm&popover): Overlay not bound to a div * docs(module:dropdown&tooltip&popconfirm&popover): unbound explanation * feat(module:OverlayTrigger): common logic relocation * feat(module:overlaytrigger): Overlay not bound to a div * feat(module:DatePicker): Overlay not bound to a div * feat(module:select): Overlay not boud to div * fix(module:select): onclickarrow event relocation * fix(module:select): rename Show to OnArrowClick * feat(module:avatar): Overlay not bound to a div * docs(module:avatar): demo switch to unbound version * feat(module:autocomplete): partial OverlayTrigger not bound to a div * feat(module:slider): tooltip * docs(module:slider): tooltip * fix(module:overlay): add SetVisible method * feat: set Ref where missing, performance components register Ref when missing IsFixed flag for CascadeValue changed hard-code sequence numbers when using RenderTreeBuilder Rate component use Tooltip Unbound version Tabs test fix * fix: revert changes (accidental) * feat(module:upload): tooltip with unbound usage * feat(module:table): column use of unbound tooltip * feat(module:autocomplete):overlay unbound from div * fix(module:upload): missing div restore Co-authored-by: James Yeung <shunjiey@hotmail.com>
🤔 This is a ...
🔗 Related issue link
Eventually if implemented, fixes #898 and #383
💡 Background and solution
For the
div
-free solution, the parent element (for exampleTooltip
) needs to have a reference to its child. Here it is solved usingForwardRef
and template approach. This solution if applied to currently existingOverlayTrigger
, would unfortunately represent a breaking change. So for purpose of discussion and additional work, I created new versions ofOverlayTrigger
,Overlay
andTooltip
with suffixUnbound
:OverlayTriggerUnbound
OverlayUnbound
TooltipUnbound
Unbound
keyword should indicate that this is an overlay that is not bound to a div (or actually to anything). In the tooltipBasic.razor
demo file I also created a tooltip that uses the new approach.In below gif notice that 1st tooltip has a wrapper (uses the regular
Tooltip
) and 2nd tooltip does not have any wrapper but directly shows the tooltip's child element<span>
(uses newly createdTooltipUnbound
).Also - this example is not yet fully done for trigger. Because the events can no longer be attached to
div
, they are attached to child element using the reference (ForwardRef
). This PR in current state does not handle@oncontextmenu
event. But it should handle all the other events that are defined on the regularTooltip
. I guess the@oncontextmenu
event can be implemented in the same manner as the other events.📝 Changelog
☑️ Self Check before Merge