grantm / sudoku-web-app

A Sudoku web app - as used on SudokuExchange.com
GNU Affero General Public License v3.0
49 stars 22 forks source link

Add a key to invert selection #57

Closed goodspark closed 1 year ago

goodspark commented 1 year ago

Sometimes it's useful

grantm commented 1 year ago

Hi - thanks for your contribution.

Are you sure that your pull request includes the version of code you intended? It doesn't seem to work for me.

For it to work, this function:

    invertSelection: (c) => {
        c.set('isSelected', !c.get('isSelected'));
        return c;
    },

would need to change to:

    invertSelection: (c) => {
        return c.set('isSelected', !c.get('isSelected'));
    },

Because the Map object used to represent the state of a cell is immutable, c.set() doesn't change the value of a property, it returns a whole new Map object which is a copy of the original but with the new value for the property. The code you submitted didn't do anything with the return value from c.set() so it was just returning the original unchanged version of c.

Having said all that, I'm really not convinced the feature would be useful often enough to justify including it so I'm just going to close this PR for now.

Thanks anyway Grant