Skip to content

Commit

Permalink
Link: Make CustomMatch enough to match the URL (#5724)
Browse files Browse the repository at this point in the history
* Link: Make CustomMatch enough to match the URL

* Add region
  • Loading branch information
stsrki authored Sep 20, 2024
1 parent bbb54f9 commit 70f7ce0
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,7 @@
URL matching behavior for a link.
</DocsAttributesItem>
<DocsAttributesItem Name="CustomMatch" Type="Func<string, bool>" Default="null">
A callback function that is used to compare current uri with the user defined uri. Must enable <Code>Match="Match.Custom"</Code> to be used.
</DocsAttributesItem>
<DocsAttributesItem Name="CustomMatch" Type="Func<string, bool>" Default="null">
A callback function that is used to compare current uri with the user defined uri. Must enable <Code>Match.Custom</Code> to be used.
A callback function that is used to compare current uri with the user defined uri. If defined, the <Code>Match</Code> parameter will be ignored.
</DocsAttributesItem>
<DocsAttributesItem Name="Title" Type="string" Default="null">
Defines the title of a link, which appears to the user as a tooltip.
Expand Down
4 changes: 2 additions & 2 deletions Source/Blazorise/Base/BaseLinkComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private bool ShouldMatch( string currentUriAbsolute )
return true;
}

if ( Match == Match.Custom && CustomMatch is not null && CustomMatch.Invoke( currentUriAbsolute ) )
if ( CustomMatch is not null && CustomMatch.Invoke( currentUriAbsolute ) )
{
return true;
}
Expand Down Expand Up @@ -268,7 +268,7 @@ private static bool IsStrictlyPrefixWithSeparator( string value, string prefix )
[Parameter] public Match Match { get; set; }

/// <summary>
/// A callback function that is used to compare current uri with the user defined uri. Must enable <see cref="Match.Custom"/> to be used.
/// A callback function that is used to compare current uri with the user defined uri. If defined, the <see cref="Match"/> parameter will be ignored.
/// </summary>
[Parameter] public Func<string, bool> CustomMatch { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion Source/Blazorise/Components/Bar/BarLink.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected Task ClickHandler( MouseEventArgs eventArgs )
[Parameter] public Match Match { get; set; } = Match.All;

/// <summary>
/// A callback function that is used to compare current uri with the user defined uri. Must enable <see cref="Match.Custom"/> to be used.
/// A callback function that is used to compare current uri with the user defined uri. If defined, the <see cref="Match"/> parameter will be ignored.
/// </summary>
[Parameter] public Func<string, bool> CustomMatch { get; set; }

Expand Down
7 changes: 6 additions & 1 deletion Source/Blazorise/Enums/Match.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
namespace Blazorise;
#region Using directives
using System;
#endregion

namespace Blazorise;

/// <summary>
/// Modifies the URL matching behavior for a link.
Expand All @@ -18,5 +22,6 @@ public enum Match
/// <summary>
/// Specifies that the link should be active when it matches the supplied <see cref="BaseLinkComponent.CustomMatch"/> method callback.
/// </summary>
[Obsolete( "Custom match is obsolete and should be removed in future versions." )]
Custom,
}
2 changes: 1 addition & 1 deletion Source/Extensions/Blazorise.Sidebar/SidebarLink.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public bool Visible
[Parameter] public Match Match { get; set; } = Match.All;

/// <summary>
/// A callback function that is used to compare current uri with the user defined uri. Must enable <see cref="Match.Custom"/> to be used.
/// A callback function that is used to compare current uri with the user defined uri. If defined, the <see cref="Match"/> parameter will be ignored.
/// </summary>
[Parameter] public Func<string, bool> CustomMatch { get; set; }

Expand Down

0 comments on commit 70f7ce0

Please sign in to comment.