Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3198,6 +3198,11 @@
Gets or sets a value indicating whether the tooltip is visible.
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.Components.Tooltip.TooltipOptions.AdditionalAttributes">
<summary>
Gets or sets a collection of additional attributes that will be applied to the created element.
</summary>
</member>
<member name="T:Microsoft.FluentUI.AspNetCore.Components.Components.Tooltip.TooltipService">
<inheritdoc cref="T:Microsoft.FluentUI.AspNetCore.Components.Components.Tooltip.ITooltipService"/>
</member>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

<FluentTooltip Anchor="myFirstButton" OnDismissed="OnDismiss">
Hello World <br />
It is a <i>small</i> tootip.
It is a <i>small</i> tooltip.
</FluentTooltip>

@code {
private void OnDismiss()
{
DemoLogger.WriteLine("Tooltip dismissed!");
}
}
}
2 changes: 1 addition & 1 deletion src/Core/Components/Tooltip/FluentTooltip.razor
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
vertical-viewport-lock="@VerticalViewportLock"
role="tooltip"
@ontooltipdismiss="HandleDismissed"
@attributes="AdditionalAttributes">
@attributes="@AdditionalAttributes">
@if (string.IsNullOrWhiteSpace(MaxWidth ?? GlobalOptions?.MaxWidth))
{
@ChildContent
Expand Down
11 changes: 8 additions & 3 deletions src/Core/Components/Tooltip/FluentTooltip.razor.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// ------------------------------------------------------------------------
// MIT License - Copyright (c) Microsoft Corporation. All rights reserved.
// ------------------------------------------------------------------------

using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.FluentUI.AspNetCore.Components.Components.Tooltip;
Expand Down Expand Up @@ -69,7 +73,7 @@ public partial class FluentTooltip : FluentComponentBase, IDisposable
public string Anchor { get; set; } = string.Empty;

/// <summary>
/// Gets or sets the delay (in milliseconds).
/// Gets or sets the delay (in milliseconds).
/// Default is 300.
/// </summary>
[Parameter]
Expand Down Expand Up @@ -116,7 +120,7 @@ public partial class FluentTooltip : FluentComponentBase, IDisposable

/// <summary>
/// Callback for when the tooltip is dismissed.
/// </summary>
/// </summary>
[Parameter]
public EventCallback<EventArgs> OnDismissed { get; set; }

Expand All @@ -136,7 +140,7 @@ private void HandleDismissed()
/// <summary />
protected override void OnInitialized()
{
HideTooltipOnCursorLeave = HideTooltipOnCursorLeave ?? LibraryConfiguration?.HideTooltipOnCursorLeave;
HideTooltipOnCursorLeave ??= LibraryConfiguration?.HideTooltipOnCursorLeave;
_tooltipService = ServiceProvider?.GetService<ITooltipService>();

if (TooltipService != null && UseTooltipService)
Expand All @@ -151,6 +155,7 @@ protected override void OnInitialized()
Position = Position,
OnDismissed = OnDismissed,
Visible = Visible,
AdditionalAttributes = AdditionalAttributes,
});
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/Core/Components/Tooltip/FluentTooltipProvider.razor
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
Delay="@item.Delay"
Position="@item.Position"
OnDismissed="@item.OnDismissed"
UseTooltipService="false">@item.ChildContent</FluentTooltip>
UseTooltipService="false"
AdditionalAttributes="@item.AdditionalAttributes">
@item.ChildContent
</FluentTooltip>
}
}
</div>
13 changes: 9 additions & 4 deletions src/Core/Components/Tooltip/Services/TooltipOptions.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// ------------------------------------------------------------------------
// MIT License - Copyright (c) Microsoft Corporation. All rights reserved.
// ------------------------------------------------------------------------

using Microsoft.AspNetCore.Components;

namespace Microsoft.FluentUI.AspNetCore.Components.Components.Tooltip;
Expand Down Expand Up @@ -31,24 +35,25 @@ public class TooltipOptions
/// Gets or sets the delay (in milliseconds).
/// Default is 300.
/// </summary>
[Parameter]
public int? Delay { get; set; } = TooltipGlobalOptions.DefaultDelay;

/// <summary>
/// Gets or sets the tooltip's position. See <see cref="TooltipPosition"/>.
/// </summary>
[Parameter]
public TooltipPosition? Position { get; set; }

/// <summary>
/// Callback for when the tooltip is dismissed.
/// </summary>
[Parameter]
public EventCallback<EventArgs> OnDismissed { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the tooltip is visible.
/// </summary>
[Parameter]
public bool Visible { get; set; }

/// <summary>
/// Gets or sets a collection of additional attributes that will be applied to the created element.
/// </summary>
public virtual IReadOnlyDictionary<string, object>? AdditionalAttributes { get; set; }
}
6 changes: 5 additions & 1 deletion src/Core/Components/Tooltip/Services/TooltipService.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// ------------------------------------------------------------------------
// MIT License - Copyright (c) Microsoft Corporation. All rights reserved.
// ------------------------------------------------------------------------

namespace Microsoft.FluentUI.AspNetCore.Components.Components.Tooltip;

/// <inheritdoc cref="ITooltipService"/>
Expand Down Expand Up @@ -44,7 +48,7 @@ public IEnumerable<TooltipOptions> Tooltips
}

/// <summary />
private IList<TooltipOptions> TooltipList { get; } = new List<TooltipOptions>();
private List<TooltipOptions> TooltipList { get; } = [];

/// <summary />
private ReaderWriterLockSlim TooltipLock { get; } = new ReaderWriterLockSlim();
Expand Down
Loading