Steps to reproduce:
1. Create and open a new project using Universal 3D Template
2. Open Edit > Project Settings > UI Toolkit and enable Enable StyleSheet Editing Mode
3. In the Project window, create a Style Sheet (Create > UI Toolkit > Style Sheet (USS))
4. Double-click the .uss asset to open it in the UI Builder
5. Click the “Add new selector...” field in the StyleSheets pane
6. Type # and press Enter
7. Observe the Console window
Actual results:
NullReferenceException: Object reference not set to an instance of an object. escapes the submit handler:
Unity.UI.Builder.BuilderSharedStyles.CreateNewSelectorElement (BuilderSharedStyles.cs:293)
Unity.UI.Builder.BuilderSharedStyles.CreateNewSelector (BuilderSharedStyles.cs:191)
Unity.UI.Builder.BuilderStyleSheets.CreateNewSelector (BuilderStyleSheets.cs:223)
Unity.UI.Builder.BuilderStyleSheets.OnNewSelectorSubmit (BuilderStyleSheets.cs:157)
Same exception for :, >, ::, # (hash + space) and .#. By contrast *, [foo], .1bad and #é are accepted silently, and . or an empty string are rejected silently. No rule is added and the sheet is not corrupted, the selector count stayed at 5 across six thrown exceptions.
Expected results: An invalid selector string is rejected with the field’s existing validation feedback, not an unhandled exception.
Reproducible with versions: 6000.7.0b1, 7000.0.0a1
Can’t test with versions: 6000.6.2f1 and lower (Feature not available)
Tested on (OS): macOS 26.6.1 (Apple silicon)