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
v7.0.0 Migration Guide #8447
Comments
When is it expected to be released |
I just want to say that I am very excited for this release! Huge thank you to everyone who contributed their time and energy to making this happen 🙏 |
I'm glad that you've been giving Obsolete warnings throughout the lifetime of v6.x. I wish the Blazor compiler did more to help raise those when compiling, but that's on Microsoft to fix. You guys have done a fantastic job, and thank you for only breaking on a major release, and not a minor one like Microsoft's Graph package. You're doing a fantastic job, and this migration guide is invaluable! |
Yes, but not all breaking changes we made in v7 have been preceeded by obsoletion warnings. While working on v7 we discovered a lot more inconsistencies and rectified them on the spot.
Yes, but we have added runtime exceptions for renamed parameters and there is also a new approach in the works by @peterthorpe81 who is tinkering with a compile time analyzer: #8771 (comment) |
Some things I ran into that I could not find in this guide:
For |
Thanks for reporting @digitaldirk, I've updated the guide. |
Minor one for |
Hmm, maybe we should revert that to false? Sounds like an oversight to me. Edit: done in f98e9a1 |
Created a discussion topic MudBlazor v7 Feedback |
MudToggleGroup removed Dense, you get an error but not in this guide @henon |
Hi, I need some help with using the |
Can you provide more details on the problem you are experiencing and show your code? If you need to update the |
Of course! I use <MudChipSet T="MyEnymFlags" SelectionMode="SelectionMode.MultiSelection" @bind-SelectedValues="SelectedFlags">
@foreach (var value in Enum.GetValues<MyEnymFlags>())
{
<MudChip Color="Color.Primary" Variant="Variant.Text" Size="Size.Small" Value="@value">@value.Humanize(LetterCasing.Sentence)</MudChip>
}
</MudChipSet> and public List<MyEnum> SelectedFlags { get; set; } = new(); With the provided code, I get Idon't want to use the So, to summarize what I'm trying to fix: I want to be able to edit the collection's values from the |
@Joedmin Here is how you update the collection: // add values to the flags:
SelectedFlags = SelectedFlags.Concat(new[] { MyEnum.Value69 }).ToList();
// remove values from the flags:
SelectedFlags.Remove(MyEnum.Value69);
SelectedFlags = SelectedFlags.ToList(); To sum up, you need to pass a different list every time it changes so that we can detect the change. If you pass the same list reference chipset will think nothing has changed because it doesn't expect a read-only collection to change. Edit: To get rid of your error you need to change
to
and change the selected flags like I showed above. |
MudBlazor version 7.0.0 brings a ton of breaking changes which we can't postpone any longer as we strive for more consistency and necessary improvements. This migration guide shall make the upgrade process as easy as possible for you.
Note: Please limit discussion strictly to migration or reporting errors in this guide. Discussion about the changes itself belong in the linked PRs and will be deleted in this issue. If you want to give general feedback about version 7.0.0 you are welcome to do it in MudBlazor v7 Feedback.
Note
v7.0.0 is currently in preview stage, you will find the nuget if you check the
Include prerelease
checkbox in Visual Studio. Please expect a few more breaking changes until we finally enter the release-candidate stage.Warning
Many parameters have been renamed to make the API more consistent, i.e.
IsEnabled
=>Enabled
. Please be aware that the compiler will NOT throw errors for unknown parameters in razor because of attribute splatting. This means, that you have to be extra careful when migrating your application from v6.x.x to v7.0.0. This is why we added an illegal parameter detection logic inMudComponentBase
which will throw a runtime exception if you forgot to rename any parameters in your razor files. You can opt-out of this behavior by settingMudGlobal.EnableIllegalRazorParameterDetection = false
in your app at startup. If you derived your own components from ourMudComponentBase
you can override the detection functionDetectIllegalRazorParametersV7()
for your own components. #8771 By the way, you can also use the compile-time Razor analyzer by meziantou which will give you a compiler warning for all unknown parameters.How to Use this Guide
Since the guide itself is quite lengthy you probably won't need to read it all. But you should read all the Warning boxes as they are very important.
It is probably best if you just compile your app against the v7 nuget and use browser search to find the new parameter or method name for the renamed parameters in this guide. Once your app runs again make sure you run all your tests to find additional problems in razor which will surface as
ArgumentExceptions
. If you don't have full test coverage then it is advised that you do a full manual test by visiting every razor component of your UI..NET 6 is not supported any longer
If you need .NET 6 support you can stay on the latest v6.x.x version. If you need any bug fixes in v6 please PR and we'll release v6 updates for you.
For more details see #8441
ICommand no longer supported
This concerns the components: MudBaseButton, MudButton, MudIconButton, MudFab, MudChip, MudListItem, MudBaseSelectItem, MudNavLink, MudMenu, MudMenuItem, MudOverlay, MudTreeViewItem, MudTableBase, MudTable
Command
+CommandParameter
withEventCallback<MouseEventArgs> OnClick
For more details see #8436
Unified Breakpoint Services
The services
SubscriptionInfo
,ResizeService
,ResizeListenerService
,ResizeBasedService
andBreakpointService
have been removed and are replaced entirely byBrowserViewportService
.For more details see #8467
Service Configuration
Some MudBlazor services hat config methods where you could directly pass options. These have been removed in favor of overloads where you pass an
Action<SomeServiceOptions>
which then manipuluates the options. The removed overloads are:AddMudBlazorSnackbar
AddMudBlazorResizeListener
AddMudBlazorResizeObserver
AddMudBlazorResizeObserverFactory
AddMudPopoverService
AddMudServices
For details see #8531
Async Protected Methods now bear the Async Postfix
Several protected
async
methods were renamed to bear theAsync
postfix to comply with our naming rules. For the most part we don't list them here as they are not important for most users except those few who derived own components from ours.Changes to Inputs
These changes concern MudTextField, MudInput and all inheriting from MudBaseInput
OnKeyPress
is no longer supported. UseOnKeyDown
instead.InvokeKeyPress
was removedIf an input has no label, it now automatically shrinks in height by 4px:
For details see #8476 and #8540
Pickers
This concerns the components MudPicker, MudColorPicker, MudBaseDatePicker, MudDatePicker, MudDateRangePicker, MudTimePicker
ClassAction
withActionsClass
#8489InputIcon (removed obsolete)
withAdornmentIcon
InputVariant (removed obsolete)
withVariant
AllowKeyboardInput
(removed, unused)ClassActions
withActionsClass
Classnames
withClassname
Close()
withCloseAsync()
Async
postfixFor details see #8506 and #8517
IMudStateHasChanged related
To force a render update cast the component in question to
IMudStateHasChanged
and callStateHasChanged()
on it. Other public ways to force a refresh have been removedForceRender
&StateHasChanged
removed #8477, #8610ForceRender
removed #8532Refresh
removed #8610Update
removed #8610Accessability Changes
Typo.subtitle1
andTypo.subtitle2
now render as<span>
instead of<h6>
#6061Inline
was removed. Instead ofInline="true"
useHtmlTag="span"
, the default tag remains<p>
. #8916Renamed Components
MudAppBarSpacer
andMudToolBarSpacer
withMudSpacer
#8475MudTextFieldString
withMudTextfield<string>
#8475Gray is the new Grey
All usage of
grey
was renamed togray
inColors
,Palette
and in css variables and classes. For more Details see #8452MudTheme
Palette
has been made abstract. #8453MudTheme.Palette
is nowPaletteLight
and is of typePaletteLight
to matchPaletteDark
. #8453ChipDefault
andChipDefaultHover
color settings have been removed fromMudPalette
, the chips now use the normal palette settings. #8599MudThemeProvider
MudThemingProvider
. #8712Warning
It's now explicitly required to add
MudPopoverProvider
. #8712Before (v6.x.x):
After (v7.x.x):
Icons
Icons.Filled
withIcons.Material.Filled
Icons.Outlined
withIcons.Material.Outlined
Icons.Rounded
withIcons.Material.Rounded
Icons.Sharp
withIcons.Material.Sharp
Icons.TwoTone
withIcons.Material.TwoTone
See #8421, #8536 for more details.
Inverted Negative Parameters
For more consistency negative parameter names were renamed and inverted. You need to do the same, make sure to invert the boolean value or condition for these parameters! This change concerns the components: MudButton, MudSelectItem, MudFab, MudToggleIconButton, MudCheckBox, MudListItem, MudMenu, MudNavGroup, MudRadio, MudRatingItem, MudSwitch, MudToggleGroup, MudList, MudListItem, AppBar, ToolBar, ExpansionPanel and possibly some others as well:
DisableRipple
withRipple
and invert the value. #8571DisableGutters
withGutters
and invert the value. #8580DisablePadding
withPadding
and invert the value. #8613DisableElevation
withDropShadow
and invert the value #8592DisableUnderLine
withUnderline
and invert the value #8591DisableRowsPerPage
withPageSizeSelector
and invert the value. #8662DisableLegend
withShowLegend
and invert value #8826DisableToolbar
withShowToolbar
and invert value #8826DisableToolbar
withShowToolbar
and invert value #8826DisableSidePadding
withGutters
and invert value #8826DisableOverlay
withOverlay
and invert value #8826DisableSliderAnimation
withSliderAnimation
and invert value #8826DisableModifiers
withModifiers
and invert value #8826Other changes
DoubleExtentions
withDoubleExtensions
#8473ToDescriptionString
enum extension has been removed. If you used this, please copy our code from the v6 branch to your own project. #8474Link
withHref
inMudChip
,MudMenuItem
,MudButton
,MudIconButton
,MudFab
andMudBaseButton
#8471Item
now usesIReadOnlyList
instead ofList
. #4728Bottom
,Left
,Start
withOrigin
#8475Delayed
withDelay
#8475OverFlowBehavior.FilpOnOpen
withFlipOnOpen
#8475Select
renamed toSelectAsync
#8477ClearAsync
withClear
#8477AndForget
with enum parameter was removed in favor of one with a bool parameter. See #8531AreEqual
removed, useDoubleEpsilonEqualityComparer.Default.Equals
#8531ColorManager
andColorTransformation
removed in favor ofMudColor
#8531AlertTextPosition
withContentAlignment
#8532ShowDelimiters
withShowBullets
andDelimitersColor
withBulletsColor
#8532InterpolationRequired
removed fromILineInterpolator
andNoInterpolation
class removed. There is no replacement #8532AnimationEnd
withAnimationEndAsync
#8532Reset
withResetAsync
#8532Minimum
withMin
andMaximum
withMax
#8532Option
withValue
#8532ResetValue
withResetValueAsync
#8532Icon
withStartIcon
#8532Checked
withValue
#8564Async
postfix. The obsolete propertySelector
was removed. #8564mud-tabs-toolbar
tomud-tabs-tabbar
in all css classes, i.e.: Usemud-tabs-tabbar-transparent
instead ofmud-tabs-toolbar-transparent
. #8569Direction
,OffsetX
,OffsetY
withAnchorOrigin
andTransformOrigin
#8475Outline
toOutlined
#8616Dense
in favor ofSize
#8676Image
andAlt
parameters. Replaced with aMudImage
as the ChildContent instead #8648Text
and constrained type parameter toINumber
. #8745IsExpandedChanged
withExpandedChanged
#8718IsEnabled
withEnabled
#8764IsEnabled
withEnabled
#8764UnCheckedColor
withUncheckedColor
#8759VerticalAlign
toVertical
#8798IsChecked
withChecked
#8825IsCheckable
withCheckable
#8825IsChecked
withChecked
#8825IsCheckable
withCheckable
#8825IsChecked
withChecked
#8825IsCheckable
withCheckable
#8825IsChecked
withChecked
#8825IsCheckable
withCheckable
#8825IsCheckedChanged
withCheckedChanged
#8825IsChecked
withChecked
#8825ToolBarClass
withToolbarClass
#8826NullableValue
instead ofValue
if you need to bind a nullable type #8881ValueLabelContent
changed fromRenderFragment<T>
toRenderFragment<SliderContext<T>>
#8881Href
is set the underlying html element is rendered as<a>
instead of<div>
#8649IsSelected
withSelected
#8886AppbarMinHeight
. #8568ItemIsDisabled
withItemDisabled
#8887ItemIsDisabled
withItemDisabled
#8887IsActive
withActive
#8888IsOpened
withOpen
#8891IsOpenChanged
withOpenChanged
#8891IsOpen
withOpen
#8891IsHidden
withHidden
#8952IsHiddenChanged
withHiddenChanged
#8952MudAutocomplete
SearchFunc
got an extra argument for a CancellationToken andSearchFuncWithCancel
was removed #8490increment
parameter was removed from theScrollToListItem
method #8477Direction
withAnchorOrigin
orTransformOrigin
#8532OffsetX
withAnchorOrigin
orTransformOrigin
#8532OffsetY
withAnchorOrigin
orTransformOrigin
#8532ChangeMenuAsync
withOpenMenuAsync
andCloseMenuAsync
#8787SelectOnClick
toSelectOnActivation
#8787IsOpenChanged
withOpenChanged
#8891IsOpen
withOpen
#8891ItemDisabledTemplate
andItemSelectedTemplate
will now display even ifItemTemplate
is not defined. #8913SelectOption
toSelectOptionAsync
#8990Clear
toClearAsync
#8990MudChipSet and MudChip
Both are now generic and
MudChipSet<T>
selection is now data driven which means that it only selects values not MudChips.<MudChip>
with<MudChip T="string">
or any other type forT
except if it is used inside aMudChipSet
from which it automatically inherits the type parameter. #4342<MudChipSet>
with<MudChipSet T="string">
or any other type forT
. #4342Avatar
andAvatarClass
withAvatarContent
#4342Link
withHref
#4342Filter
withCheckMark
#4342DisableRipple
withRipple
but make sure to invert the boolean expression. #4342Value
instead ofText
, useText
only for displaying a different text than the assigned value. Only forT="string"
when you don't setValue
thenText
is used instead as before. For all other types, you must setValue
. #4342MultiSelection
andMandatory
withSelectionMode
.MultiSelection="true"
corresponds toSelectionMode.MultiSelection
. For the default single-selection of the old chip set useSelectionMode.ToggleSelection
. The oldMultiSelection="false" Mandatory="true"
corresponds toSelectionMode.SingleSelection
. #8722Correspondence of old parameters to the new selection mode (#8722):
true
SelectionMode.MultiSelection
false
true
SelectionMode.SingleSelection
false
false
SelectionMode.ToggleSelection
Warning
Due to the unification of selection features over all components the default selection mode of MudChipSet has changed. Prior to v7 chips could be selected off by default. In v7 the default is
SelectionMode.SingleSelection
(like for all other components that support parameterSelectionMode
) which does not allow to de-select chips by clicking again. Set toSelectionMode.ToggleSelection
for that. #8722SelectedChip
andSelectedChips
withSelectedValue
andSelectedValues
#4342IsSelected
withSelected
#8886IsSelectedChanged
withSelectedChanged
#8886MudColorPicker
DisableSliders
withShowSliders
and invert value #8826DisablePreview
withShowPreview
and invert value #8826DisableModeSwitch
withShowModeSwitch
and invert value #8826DisableInputs
withShowInputs
and invert value #8826DisableDragEffect
withDragEffect
and invert value #8826DisableColorField
withShowColorField
and invert value #8826DisableAlpha
withShowAlpha
and invert value #8826MudDialog
The changes below concern the classes
MudDialog
,MudDialogOptions
,MudDialogInstance
andMudDialogProvider
andDialogResult
ClassBackground
withBackgroundClass
#8458ClassAction
withActionsClass
#8481ClassContent
withContentClass
#8481AreParametersRendered
was removed, it had no function #8475Cancelled
withCanceled
#8475MudBlazor.Dialog
was removed completely. #8564DisableBackdropClick
toBackdropClick
and invert the conditionpublic DialogService
was madeprotected
. #8925Show()
renamed toTask ShowAsync()
. #8925Close()
renamed toTask CloseAsync()
. #8925MudDrawer
DrawerWidth
. #8568DrawerHeightTop
. #8568DrawerHeightBottom
. #8568MudExpansionPanels
IsExpanded
withExpanded
#8718IsExpandedChanged
withExpandedChanged
#8718IsInitiallyExpanded="true"
withExpanded="true"
or use@bind-Expanded="_expanded"
where_expanded
istrue
as initial value.CollapseAll()
withCollapseAllAsync()
CollapseAllExcept(...)
withCollapseAllExceptAsync(...)
CloseAllExcept()
withCollapseAllExceptAsync(...)
ExpandAll()
withExpandAllAsync()
UpdateAll()
withUpdateAllAsync()
RemovePanel(...)
is not public any more. If you used it, you have to change your code to a more blazoresque coding style where the panels are created from a list. Removing a panel can then be done by removing it from the list and callingStateHasChanged
.For more details see #8446
MudExpansionPanel
ToggleExpansion()
withToggleExpansionAsync()
Expand()
withExpandAsync()
Collapse()
withCollapseAsync()
For more details see #8446
MudFileUpload
For more details see #6483
ButtonTemplate
withActivatorContent
. AnyMudButton
withinActivatorContent
now activates the file picker. #8694MudFormComponent
This concerns all inputs which inhert from MudFormComponent, such as MudTextField, MudCheckBox, MudSwitch, MudFileUpload, etc.
BeginValidateAfter
withBeginValidationAfterAsync
andBeginValidate
withBeginValidateAsync
#8564Reset
andResetValue
withResetValueAsync
#8564MudGrid
Warning
To unify spacing accross the library the default spacing unit in MudGrid was changed (halved from 8px to 4px). To keep the gaps the same as in v6 you need to double the value of the
Spacing
parameter. #8910If you didn't set a value vor
Spacing
, you don't have to do anything as we already doubled the default value. Of course the maximum allowable spacing has also been increased from 10 to 20.MudList
MudList
andMudListItem
are now generic<T>
so you can bind any type toSelectedValue
. This means you now must specifyT
, even if you don't use the selection feature. #8613SelectedItem
has been removed. The selection is solely managed viaSelectedValue
which you should bind. #8613Clickable
toReadOnly
and inverted conditions. #8613SelectedValue
. Lists are interactive by default now. If the list isReadOnly
, the selection will still be shown but can't be changed, ifDisabled
no selection shows. #8613DisablePadding
toPadding
and inverted conditions #8613Avatar
andAvatarClass
in favor ofAvatarContent
render fragment #8677InitiallyExpanded
, just setExpanded
totrue
#8613T="string"
, you can just setText
if theValue
is the same so you don't have to repeat yourself. This also means you don't have to set a value if you only have a (unique)Text
and you won't get selection problems. In the old list you had to set a uniqueValue
just so the selection mechanism worked. #8613AdornmentColor
withExpandIconColor
#8775OnClickHandlerPreventDefault
toOnClickPreventDefault
#8775MudRadioGroup
ResetValue
renamed toResetValueAsync
. #8477SelectedOption
withValue
instead. #8568SelectedOptionChanged
withValueChanged
instead. #8568MudSelect
Direction
withAnchorOrigin
orTransformOrigin
#8532OffsetX
withAnchorOrigin
orTransformOrigin
#8532OffsetY
withAnchorOrigin
orTransformOrigin
#8532MudSnackbar
SnackbarService
methodAddNew
withAdd
#8475Add(string message, ...)
does not supportMarkupString
any longer for security reasons. We added an overloadAdd(MarkupString message, ...)
. #8156MudSwipeArea
GetSwipeDelta
removed. UseOnSwipeEnd
instead #8568OnSwipe
removed. UseOnSwipeEnd
instead #8568MudTable
ServerData
got an extra argument for a CancellationToken #8407RightAlignSmall
removed as not needed any longer, the cells width/alignment is done automatically.. #8532DisableRowsPerPage
withHideRowsPerPage
#8532IsExpandable
withExpandable
#8718IsExpandable
withExpandable
#8718IsExpanded
withExpanded
#8718IsExpandable
withExpandable
#8718IsEditable
withEditable
#8892IsEditing
andIsEditSwitchBlocked
#8892IsEditable
withEditable
#8892QuickColumns
property andMudColumn
that was used to generate table when no Columns and Rows were present. We no longer want to use reflection in MudTable, so we removed this undocumented feature. #8927PointerEventArgs
instead ofMouseEventArgs
#8974MudTreeView
CanActivate
was removed, it is no longer needed. #8475CanHover
withHover
#8475CanSelect
removed. Use MultiSelection instead #8532ActivatedValueChanged
withSelectedValueChanged
#8532ReadOnly
for a non-selectable treeview. #8661Multiselection
has been replaced by parameterSelectionMode
with enum values{ SingleSelection, MultiSelection, ToggleSelection }
#8661Items
now usesIReadOnlyCollection<T>
#8661Actived
was removed. UseSelected
instead #8661Warning
MudTreeViewItem: Parameter
ExpandedIcon
was removed. UseExpandButtonIcon
instead to set a custom glyph for the expand button. This is not to be confused with the new parameterIconExpanded
which is a new feature to allow showing an alternate icon in expanded state instead ofIcon
. #8661Items
andServerData
now useIReadOnlyCollection<T>
#8661MudDrawer
INavigationEventReceiver.OnNavigation()
is implemented now explicitly. #8532PreserveOpenState
as it is not needed any longer. #8833MudDataGrid
FilterDefinition.GenerateFilterExpression()
replace withFilterExpressionGenerator.GenerateExpression
FilterDefinition
that was replaced byIFilterDefinition
API.FilterContext.FilterActions
all properties are marked as required.FooterContext.FooterActions
all properties are marked as required.HeaderContext.SetSelectAllAsync
all properties are marked as required.HeaderContext.IsAllSelected
changed type frombool
tobool?
.IsEditable
withEditable
For more details see #8548, #8317, #8892
MudMenu
Link
,Target
,HtmlTag
andButtonType
were removed. They had no function. #8475ToggleMenu
is renamed toToggleMenuAsync
#8317CloseMenu
is renamed toCloseMenuAsync
#8317OpenMenu
is renamed toOpenMenuAsync
#8317MouseEnter
is not public API anymore. #8317MouseLeave
is not public API anymore. #8317MudMenuItem:
UriHelper
changed visibility frompublic
toprotected
. #8317JsApiService
changed visibility frompublic
toprotected
. #8317Activate(object, MouseEventArgs)
is now implemented explicitlyIActivatable.Activate(object, MouseEventArgs)
#8317void Activate(object, TouchEventArgs)
was removed. #8317The text was updated successfully, but these errors were encountered: