Skip to content

FIX: Only dispatch when there is a valid selected item#2383

Merged
josepmariapujol-unity merged 2 commits intodevelopfrom
input/uum-137116/null-reference-expection-action-maps
Mar 16, 2026
Merged

FIX: Only dispatch when there is a valid selected item#2383
josepmariapujol-unity merged 2 commits intodevelopfrom
input/uum-137116/null-reference-expection-action-maps

Conversation

@josepmariapujol-unity
Copy link
Copy Markdown
Collaborator

@josepmariapujol-unity josepmariapujol-unity commented Mar 16, 2026

Description

This PR is fixing the NullReferenceException error that triggers when removing all action maps

The selectedIndicesChanged callback always accessed ((ActionMapData)m_ListView.selectedItem).mapName. However, when the list view is refreshed (for example in RedrawUI when itemsSource is reassigned), the framework may trigger selectedIndicesChanged while no item is selected. In that situation, m_ListView.selectedItem is null, causing the cast and property access to throw a NullReferenceException.

JIRA: https://jira.unity3d.com/browse/UUM-137116

Before:
https://github.com/user-attachments/assets/1fe91523-5b09-428e-9fa9-6e81bf1a60de

After:
https://github.com/user-attachments/assets/8e9be1f8-b2d1-4036-a440-23bfc23dfdbe

Testing status & QA

Check that no errors are thrown when removing all action maps.

Overall Product Risks

Please rate the potential complexity and halo effect from low to high for the reviewers. Note down potential risks to specific Editor branches if any.

  • Complexity: 1
  • Halo Effect: 1

Comments to reviewers

Please describe any additional information such as what to focus on, or historical info for the reviewers.

Checklist

Before review:

  • Changelog entry added.
    • Explains the change in Changed, Fixed, Added sections.
    • For API change contains an example snippet and/or migration example.
    • JIRA ticket linked, example (case %%). If it is a private issue, just add the case ID without a link.
    • Jira port for the next release set as "Resolved".
  • Tests added/changed, if applicable.
    • Functional tests Area_CanDoX, Area_CanDoX_EvenIfYIsTheCase, Area_WhenIDoX_AndYHappens_ThisIsTheResult.
    • Performance tests.
    • Integration tests.
  • Docs for new/changed API's.
    • Xmldoc cross references are set correctly.
    • Added explanation how the API works.
    • Usage code examples added.
    • The manual is updated, if needed.

During merge:

  • Commit message for squash-merge is prefixed with one of the list:
    • NEW: ___.
    • FIX: ___.
    • DOCS: ___.
    • CHANGE: ___.
    • RELEASE: 1.1.0-preview.3.

Fixed a NullReferenceException when removing all action maps and improved messaging and validation in the Input System.
@josepmariapujol-unity josepmariapujol-unity marked this pull request as ready for review March 16, 2026 12:11
@codecov-github-com
Copy link
Copy Markdown

codecov-github-com Bot commented Mar 16, 2026

Codecov Report

All modified and coverable lines are covered by tests ✅

@@            Coverage Diff            @@
##           develop    #2383    +/-   ##
=========================================
  Coverage    77.90%   77.91%            
=========================================
  Files          476      482     +6     
  Lines        97613    97756   +143     
=========================================
+ Hits         76048    76162   +114     
- Misses       21565    21594    +29     
Flag Coverage Δ
inputsystem_MacOS_2022.3 5.49% <0.00%> (-0.04%) ⬇️
inputsystem_MacOS_2022.3_project 75.42% <0.00%> (+0.02%) ⬆️
inputsystem_MacOS_6000.0 5.27% <0.00%> (-0.04%) ⬇️
inputsystem_MacOS_6000.0_project 77.32% <100.00%> (+0.03%) ⬆️
inputsystem_MacOS_6000.3 5.27% <0.00%> (-0.04%) ⬇️
inputsystem_MacOS_6000.3_project 77.32% <100.00%> (+0.03%) ⬆️
inputsystem_MacOS_6000.4 5.28% <0.00%> (-0.04%) ⬇️
inputsystem_MacOS_6000.4_project 77.33% <100.00%> (+0.03%) ⬆️
inputsystem_MacOS_6000.6_project 77.33% <100.00%> (+0.02%) ⬆️
inputsystem_Ubuntu_2022.3_project 75.22% <0.00%> (+0.02%) ⬆️
inputsystem_Ubuntu_6000.0 5.28% <0.00%> (-0.04%) ⬇️
inputsystem_Ubuntu_6000.0_project 77.13% <100.00%> (+0.03%) ⬆️
inputsystem_Ubuntu_6000.3 5.28% <0.00%> (-0.04%) ⬇️
inputsystem_Ubuntu_6000.3_project 77.13% <100.00%> (+0.02%) ⬆️
inputsystem_Ubuntu_6000.4 5.28% <0.00%> (-0.04%) ⬇️
inputsystem_Ubuntu_6000.4_project 77.14% <100.00%> (+0.02%) ⬆️
inputsystem_Ubuntu_6000.6 5.28% <0.00%> (-0.04%) ⬇️
inputsystem_Ubuntu_6000.6_project 77.13% <100.00%> (+0.02%) ⬆️
inputsystem_Windows_2022.3 5.50% <0.00%> (-0.04%) ⬇️
inputsystem_Windows_2022.3_project 75.55% <0.00%> (+0.02%) ⬆️
inputsystem_Windows_6000.0 5.27% <0.00%> (-0.04%) ⬇️
inputsystem_Windows_6000.0_project 77.45% <100.00%> (+0.03%) ⬆️
inputsystem_Windows_6000.3 5.27% <0.00%> (-0.04%) ⬇️
inputsystem_Windows_6000.3_project 77.45% <100.00%> (+0.02%) ⬆️
inputsystem_Windows_6000.4 5.28% <0.00%> (-0.04%) ⬇️
inputsystem_Windows_6000.4_project 77.45% <100.00%> (+0.02%) ⬆️
inputsystem_Windows_6000.6 5.28% <0.00%> (-0.04%) ⬇️
inputsystem_Windows_6000.6_project 77.45% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...tem/Editor/UITKAssetEditor/Views/ActionMapsView.cs 62.57% <100.00%> (+0.23%) ⬆️

... and 7 files with indirect coverage changes

Copy link
Copy Markdown
Contributor

@u-pr u-pr Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect

The PR quality is high with only a few minor documentation and maintenance findings. These are low importance and do not affect functionality.

🤖 Helpful? 👍/👎

Comment thread Packages/com.unity.inputsystem/CHANGELOG.md
Copy link
Copy Markdown
Collaborator

@MorganHoarau MorganHoarau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple and effective fix. Ship it!

@josepmariapujol-unity josepmariapujol-unity merged commit e4f2475 into develop Mar 16, 2026
106 of 128 checks passed
@josepmariapujol-unity josepmariapujol-unity deleted the input/uum-137116/null-reference-expection-action-maps branch March 16, 2026 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants