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:
https://github.com/emberjs/data/issues/1540
https://emberigniter.com/saving-only-dirty-attributes/

One gentleman's workaround to the problem:
https://gist.github.com/blimmer/cb7425d7bef06b5acb858e5f5f6a9e7a

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.