Skip to content

Commit

Permalink
Fix Tooltips (#585)
Browse files Browse the repository at this point in the history
* Paginator, Menu and MenuSurface updates

* Update release notes

* Remove debugging text

* Clarify Action names

* Fix tooltip markup to material v12

* Release Notes

* Further release notes updates

* Release notes

* Tooltip page markup improvement
  • Loading branch information
simonziegler authored Dec 4, 2021
1 parent 2007a19 commit 7650995
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 44 deletions.
16 changes: 6 additions & 10 deletions Material.Blazor.Website/Pages/Tooltip.razor
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,22 @@
</div>
<div class="mdc-layout-grid__cell--span-12">
<p>
<MBTooltip TooltipType="@MBTooltipType.Span">
<MBTooltip>
<Target>
<span style="background-color: var(--mb-color-red-100);">Tooltip applied with TooltipType="MBTooltipType.Span" using the whole paragraph as the target.</span>
<span style="background-color: var(--mb-color-red-100);">Tooltip applied using the whole paragraph as the target.</span>
</Target>
<Content>
&lt;
<strong>MBTooltip TooltipType</strong>="MBTooltipType.
<em><u>Span</u></em>"&gt;
Centred on the paragraph
</Content>
</MBTooltip>
</p>

<MBTooltip TooltipType="@MBTooltipType.Div">
<MBTooltip>
<Target>
<p style="background-color: var(--mb-color-red-100);">Tooltip applied with TooltipType="MBTooltipType.Div" using the whole div as the target.</p>
<p style="background-color: var(--mb-color-red-100);">Tooltip applied using the whole div as the target.</p>
</Target>
<Content>
&lt;
<strong>MBTooltip TooltipType</strong>="MBTooltipType.
<em><u>Div</u></em>"&gt;
Centred on the div
</Content>
</MBTooltip>
</div>
Expand Down
8 changes: 4 additions & 4 deletions Material.Blazor.Website/Styles/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
/*
Dynamic link underlining
*/
a:not(.mdc-deprecated-list-item) {
a:not(.mdc-deprecated-list-item):not(.mb-tooltip-anchor) {
position: relative;
box-shadow: inset 0 -2px 0 theme.$secondary;
display: inline-flex;
Expand All @@ -171,13 +171,13 @@
transition: 0.15s ease;
}

a:not(.mdc-deprecated-list-item):hover {
a:not(.mdc-deprecated-list-item):not(.mb-tooltip-anchor):hover {
box-shadow: none;
color: theme.$on-secondary;
text-decoration: none;
}

a:not(.mdc-deprecated-list-item)::after {
a:not(.mdc-deprecated-list-item):not(.mb-tooltip-anchor)::after {
content: "";
background: theme.$secondary;
position: absolute;
Expand All @@ -189,7 +189,7 @@
transition: 0.15s ease;
}

a:not(.mdc-deprecated-list-item):hover:after {
a:not(.mdc-deprecated-list-item):not(.mb-tooltip-anchor):hover:after {
height: 100%;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
role="tooltip"
aria-hidden="true"
style="z-index: 1000;">
<div class="mdc-tooltip__surface">
<div class="mdc-tooltip__surface mdc-tooltip__surface-animation">
@if (tooltip.RenderFragmentContent == null)
{
@tooltip.MarkupStringContent;
Expand Down
24 changes: 6 additions & 18 deletions Material.Blazor/Components/Tooltip/MBTooltip.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,9 @@
@inherits ComponentBase


@if (TooltipType == MBTooltipType.Span)
{
<span aria-describedby="mb-tooltip-@id">
@if (Target != null)
{
@Target
}
</span>
}
else
{
<div aria-describedby="mb-tooltip-@id">
@if (Target != null)
{
@Target
}
</div>
}
<a class="mb-tooltip-anchor" aria-describedby="mb-tooltip-@id">
@if (Target != null)
{
@Target
}
</a>
3 changes: 2 additions & 1 deletion Material.Blazor/Components/Tooltip/MBTooltip.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ public partial class MBTooltip : ComponentBase, IDisposable


/// <summary>
/// The tooltip's content.
/// OBSOLETE TO BE REMOVED IN VERSION 3.0.0. The tooltip type.
/// </summary>
[Obsolete]
[Parameter] public MBTooltipType TooltipType { get; set; } = MBTooltipType.Span;


Expand Down
5 changes: 3 additions & 2 deletions Material.Blazor/Model/MBEnumerations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -777,9 +777,10 @@ public enum MBToastPosition


/// <summary>
/// Determines the density of a component
/// OBSOLETE - TO BE REMOVED IN VERSION 3.0.0. Determines the density of a component.
/// <para>Defaults to <see cref="Span"/></para>
/// </summary>
[Obsolete]
public enum MBTooltipType
{
/// <summary>
Expand All @@ -788,7 +789,7 @@ public enum MBTooltipType
Span,

/// <summary>
/// Uses a &lt;div&gt; element for a tooltip - the default.
/// Uses a &lt;div&gt; element for a tooltip.
/// </summary>
Div
}
Expand Down
9 changes: 5 additions & 4 deletions articles/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ Released 2021-??-??

<br />

#### [2.0.1](https://github.com/Material-Blazor/Material.Blazor)
#### [2.0.1](https://github.com/Material-Blazor/Material.Blazor/tree/2.0.1)
Released 2021-12-04

- Fixes bug in MBPaginator where menu for number of items per pages doesn't open
- Fixes bug in MBPaginator where menu for number of items per pages doesn't open.
- Updates tooltip markup to be Material Components Web 12, fixing a bug where tooltips failed to close when the anchor loses hover state.

<br />

#### [2.0.0](https://github.com/Material-Blazor/Material.Blazor)
#### [2.0.0](https://github.com/Material-Blazor/Material.Blazor/tree/2.0.0)
Released 2021-11-10

**Updates**
Expand All @@ -50,7 +51,7 @@ Released 2021-11-10

<br />

#### [2.0.0-rc.1](https://github.com/Material-Blazor/Material.Blazor/tree/2.0.0-preview.9)
#### [2.0.0-rc.1](https://github.com/Material-Blazor/Material.Blazor/tree/2.0.0-rc.1)
2021-10-29

**Updates**
Expand Down
5 changes: 1 addition & 4 deletions articles/Tooltip.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The [MBTooltip](xref:C.MBTooltip) component gives you flexible tooltips that tak
in your page and Content for the tooltip's content, e.g.:

```html
<MBTooltip TooltipType="@MBTooltipType.Span">
<MBTooltip>
<Target>
<span style="background-color: var(--mb-color-red-100);">This is the target span to be displayed in your razor page.</span>
</Target>
Expand All @@ -30,6 +30,3 @@ in your page and Content for the tooltip's content, e.g.:
</Content>
</MBTooltip>
```

This tooltip surrounds your `<Target>` with either a span or div depending on whether the `TooltipType` is `MBTooltipType.Span` or
`MBTooltipType.Div` respectively.

0 comments on commit 7650995

Please sign in to comment.