Ember TIL: Even Null can dirty your inputs

Problem: When I clicked on a dropdown menu in a form, it would invariably trigger the save button. This would happen even if no selection was made. The mere act of touching the menu would pollute the input as if something had changed.

On further inspection, my readyToSave function that would change my save button's color (hence, telling me it was getting triggered) used Ember's hasDirtyAttributes.

hasDirtyAttributes is the new method in Ember Data (isDirty is the newly deprecated) that tells us if the state of a record has been changed. It should ignore null, but it doesn't. TIL.

Null, undefined & even an empty string was enough to dirty the input. Nothing had to change to trigger it. Seems excessive.

Here is what the Internet gave me:

One gentleman's workaround to the problem:

Solution: Instead of employing the above approaches, since I'm using the Handsontable.js library, using a simple conditional statement to ignore empty strings in my Controller did the trick.