Repository: microsoft/terminal (language: cpp)

Issue:
[Color Scheme - Camphell]: Name is not defined updated if user selects any other color.
### Windows Terminal version

1.19.2481.0

### Windows build number

23529.1000

### Other Software

Test Environment:
OS: Windows 11 Version Dev (OS Build 23529.1000)
App: Windows Terminal Preview

### Steps to reproduce

**Repro Steps: **

1.Open Windows Terminal.
2.Open Settings page using 'Ctr+,'
3. Navigate to the 'Color Scheme' and Select 'Camphell'.
4. Now navigate to any color and changed it according to your will.
5. Navigate over the color using Narrator and observe the issue.

**User Experience: **
Users who have cerebral palsy and in-active limbs and depend on Voice Access for their accessibility will not be able to access the options with its visible name if the accessible name defined is incorrect.

MAS Reference:
https://www.w3.org/WAI/WCAG21/Understanding/name-role-value

Attachment :
[Name is not defined updated if user selects any other color..zip](https://github.com/microsoft/terminal/files/12644638/Name.is.not.defined.updated.if.user.selects.any.other.color.zip)


### Expected Behavior

Name should get updated if user selects any other color.


### Actual Behavior

Name is not defined updated if user selects any other color.


Discussion / hints:
This and #15985 are the same thing - just kinda a misunderstanding of how Terminals work. You're totally free to set "Black"(and the rest of the palette) to whatever color _value_ you want. That however doesn't change the meaning of those color palette entries to CLI applications. 

This seems like by design to me honestly. 
This is correct. @Priyanka-Chauhan123, "Black", "Red", "White" and the other 13 colors in the Terminal settings are terms of art. The standard language for terminal emulators defines 16 colors that have specific names. The user is allowed to redefine how those names appear, but the names may never change.
@zadjii-msft for 15985, I wonder if it would be possible to indicate "Foreground (Ochre)" or "Background (Vermillion)"?
@carlos-zamora By when it is expected to get fixed, as it is impacting product compliance 
@Priyanka-Chauhan123 please see questions above directed towards you. These are not intended to be the names of the user's selected color, they are intended to be the name of the standard "color slot" the user is changing.
@DHowett Does it meant that user will not be able to change the color and it will not be modified. If this is the case, then it should not change the color visibly as well. 
@Priyanka-Chauhan123 It is different. In this case, "red" is a symbolic name used as part of an API contract. It's like syntax highlighting, with tokens for "error" or "filename" or "string".

We allow the user to change to meaning of the symbolic constant ("red"), just like Visual Studio lets you change the color of "String", without changing its name. Changing its name would break the API contract.

This is true of all 16 "color" names used in a terminal emulator application.

Does that help?

Fix patch:
diff --git a/src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.cpp b/src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.cpp
index 4bd995b6c4a..04e9433bbba 100644
--- a/src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.cpp
+++ b/src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.cpp
@@ -178,6 +178,8 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
         Name(TableColorNames[index]);
         Tag(winrt::box_value<uint8_t>(index));
         Color(color);
+
+        PropertyChanged({ get_weak(), &ColorTableEntry::_PropertyChangedHandler });
     }
 
     ColorTableEntry::ColorTableEntry(std::wstring_view tag, Windows::UI::Color color)
@@ -185,5 +187,17 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
         Name(LocalizedNameForEnumName(L"ColorScheme_", tag, L"Text"));
         Tag(winrt::box_value(tag));
         Color(color);
+
+        PropertyChanged({ get_weak(), &ColorTableEntry::_PropertyChangedHandler });
+    }
+
+    void ColorTableEntry::_PropertyChangedHandler(const IInspectable& /*sender*/, const PropertyChangedEventArgs& args)
+    {
+        const auto propertyName{ args.PropertyName() };
+        if (propertyName == L"Color" || propertyName == L"Name")
+        {
+            _PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"AccessibleName" });
+        }
     }
+
 }
diff --git a/src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.h b/src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.h
index 539b0636c3c..7c45638e709 100644
--- a/src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.h
+++ b/src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.h
@@ -63,6 +63,11 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
         ColorTableEntry(uint8_t index, Windows::UI::Color color);
         ColorTableEntry(std::wstring_view tag, Windows::UI::Color color);
 
+        hstring AccessibleName() const
+        {
+            return hstring{ fmt::format(FMT_COMPILE(L"{} RGB({}, {}, {})"), _Name, _Color.R, _Color.G, _Color.B) };
+        }
+
         WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
         WINRT_OBSERVABLE_PROPERTY(Windows::UI::Color, Color, _PropertyChangedHandlers);
         WINRT_OBSERVABLE_PROPERTY(winrt::hstring, Name, _PropertyChangedHandlers);
@@ -70,5 +75,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
 
     private:
         Windows::UI::Color _color;
+
+        void _PropertyChangedHandler(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::Data::PropertyChangedEventArgs& args);
     };
 };
diff --git a/src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.idl b/src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.idl
index 3247ef125e3..b041c2ab93f 100644
--- a/src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.idl
+++ b/src/cascadia/TerminalSettingsEditor/ColorSchemeViewModel.idl
@@ -34,5 +34,6 @@ namespace Microsoft.Terminal.Settings.Editor
         String Name { get; };
         IInspectable Tag;
         Windows.UI.Color Color;
+        String AccessibleName { get; };
     }
 }
diff --git a/src/cascadia/TerminalSettingsEditor/EditColorScheme.xaml b/src/cascadia/TerminalSettingsEditor/EditColorScheme.xaml
index 8e68567bb82..c98f5c8d6c4 100644
--- a/src/cascadia/TerminalSettingsEditor/EditColorScheme.xaml
+++ b/src/cascadia/TerminalSettingsEditor/EditColorScheme.xaml
@@ -55,10 +55,10 @@
 
             <DataTemplate x:Key="ColorTableEntryTemplate"
                           x:DataType="local:ColorTableEntry">
-                <Button AutomationProperties.Name="{x:Bind Name}"
+                <Button AutomationProperties.Name="{x:Bind AccessibleName, Mode=OneWay}"
                         Background="{x:Bind local:Converters.ColorToBrush(Color), Mode=OneWay}"
                         Style="{StaticResource ColorSchemesColorButtonStyle}"
-                        ToolTipService.ToolTip="{x:Bind Name}">
+                        ToolTipService.ToolTip="{x:Bind AccessibleName, Mode=OneWay}">
                     <Button.Flyout>
                         <Flyout>
                             <muxc:ColorPicker ColorChanged="ColorPickerChanged"


Test patch: