Repository: dotnet/maui
File: src/Controls/src/Core/Shell/Shell.cs (C#)

Code before:
				oldShellItem.SendDisappearing();

				foreach (var section in oldShellItem.Items)
				{
					foreach (var content in section.Items)
					{
						content.EvaluateDisconnect();
					}
				}
			}

			if (newValue == null)
				return;

			if (newValue is ShellItem newShellItem)
				newShellItem.SendAppearing();

			var shell = (Shell)bindable;
			UpdateChecked(shell);

			shell.ShellController.AppearanceChanged(shell, false);
			shell.ShellController.UpdateCurrentState(ShellNavigationSource.ShellItemChanged);

			// If the new ShellItem is a FlyoutItem or a ShellGroupItem, we need to update the QueryAttributes
			var existing = (ShellRouteParameters)shell.CurrentContent?.GetValue(ShellContent.QueryAttributesProperty);
            if(oldValue is not null && newValue is not null && (shell.CurrentItem is FlyoutItem || shell.CurrentItem is ShellGroupItem) && existing is null)
            {
                ShellContent currentShellContent = shell.CurrentItem.CurrentItem?.CurrentItem;
                currentShellContent?.SetValue(ShellContent.QueryAttributesProperty, new ShellRouteParameters());
            }

			if (shell.CurrentItem?.CurrentItem != null)
				shell.ShellController.AppearanceChanged(shell.CurrentItem.CurrentItem, false);
		}

		static void OnCurrentItemChanging(BindableObject bindable, object oldValue, object newValue)
		{
			var shell = (Shell)bindable;
			var shellItem = (ShellItem)newValue;

			if (!shell.Items.Contains(shellItem))
				shell.Items.Add(shellItem);

			var shellSection = shellItem.CurrentItem;
			var shellContent = shellSection.CurrentItem;
			var stack = shellSection.Stack;
			shell._navigationManager.ProposeNavigationOutsideGotoAsync(ShellNavigationSource.ShellItemChanged, shellItem, shellSection, shellContent, stack, false, true);
		}

		static void UpdateChecked(Element root, bool isChecked = true)
		{

Review comment (suggestion):
This is a condition with a lot of checks. Not required but, we could improve the readability with small changes:

```
bool isRelevantShellItem = shell.CurrentItem is FlyoutItem || shell.CurrentItem is ShellGroupItem;
bool isNewValueDifferent = oldValue is not null && newValue is not null && existing is null;

if (isNewValueDifferent && isRelevantShellItem)
```

Code after:
			if (oldValue is ShellItem oldShellItem)
			{
				oldShellItem.SendDisappearing();

				foreach (var section in oldShellItem.Items)
				{
					foreach (var content in section.Items)
					{
						content.EvaluateDisconnect();
					}
				}
			}

			if (newValue == null)
				return;

			if (newValue is ShellItem newShellItem)
				newShellItem.SendAppearing();

			var shell = (Shell)bindable;
			UpdateChecked(shell);

			shell.ShellController.AppearanceChanged(shell, false);
			shell.ShellController.UpdateCurrentState(ShellNavigationSource.ShellItemChanged);

			// If the new ShellItem is a FlyoutItem or a ShellGroupItem, we need to update the QueryAttributes
			var existing = (ShellRouteParameters)shell.CurrentContent?.GetValue(ShellContent.QueryAttributesProperty);
			bool isRelevantShellItem = shell.CurrentItem is FlyoutItem || shell.CurrentItem is ShellGroupItem;
			bool isNewValueDifferent = oldValue is not null && newValue is not null && existing is null;

			if (isNewValueDifferent && isRelevantShellItem)
			{
				ShellContent currentShellContent = shell.CurrentItem.CurrentItem?.CurrentItem;
				currentShellContent?.SetValue(ShellContent.QueryAttributesProperty, new ShellRouteParameters());
			}

			if (shell.CurrentItem?.CurrentItem != null)
				shell.ShellController.AppearanceChanged(shell.CurrentItem.CurrentItem, false);
		}

		static void OnCurrentItemChanging(BindableObject bindable, object oldValue, object newValue)
		{
			var shell = (Shell)bindable;
			var shellItem = (ShellItem)newValue;

			if (!shell.Items.Contains(shellItem))
				shell.Items.Add(shellItem);

			var shellSection = shellItem.CurrentItem;
			var shellContent = shellSection.CurrentItem;
			var stack = shellSection.Stack;