jquery-flexselect icon indicating copy to clipboard operation
jquery-flexselect copied to clipboard

Minor bug fixes

Open colbysargentcodes opened this issue 7 years ago • 3 comments

Line 108: Show results if picked option is blank. If a blank option was present, results would previously not show on focus.

Line 315: Change setValue.val(""); to setValue("");. This will now set original select's value to blank as intended. Previously this would have no effect and instead keep previously selected values. Fixes issues #13 and #37.

colbysargentcodes avatar Apr 13 '17 16:04 colbysargentcodes

This appears to break the general allowMismatch usage. Testing it, it appears that it's now no longer possible to write in a custom mismatch value.

rmm5t avatar Apr 13 '17 17:04 rmm5t

Apologies, forgot to copy over one more change from my own copy.

Also when retesting I noticed there's no setValue call onblur when using a mismatch, so will add this too and update soon.

colbysargentcodes avatar Apr 13 '17 17:04 colbysargentcodes

Ok, came to realise the method I used may not be suitable for all cases (I was simply setting the value to blank and not triggering the change event if allowMismatch was true), so I've been trying to improve it a little. I've come into a couple issues... (this may be better suited in an issue thread, I'll open it if you prefer to discuss there).

  1. In my particular case, I had a blank value, so using setValue("") was fine. But in cases where there is no blank value, the original select would be set to the first option. This change event then causes the flexselect to update to the original select value.

  2. From what I can tell, allowMismatchBlank is currently useless, within the settings there is the comment: allowMismatchBlank: true, //If "true" a user can backspace such that the value is nothing (even if no blank value was provided in the original criteria) This isn't true, this also sets the value back to the first option of the original select. And if there is a blank value, it doesn't require any mismatch setting anyway.

Both of these can be fixed by appending a blank option on init, but the following issue still exists:

  1. due to the setValue triggering a change on the original select, the flexselect is still updated to match to either the blank value or text of an original blank value. (for example <option value=''>Select One...</option>

Proposed change

  • on init, if allowMismatch or allowMismatchBlank are true, append a blank option with an id/attribute for reference back to it.
  • add a mismatch parameter on setValue, which selects the option created above as opposed to the first blank value (due to issue 3)
  • on original select change, if the created blank option is selected, do not update val of flexselect

Unfortunately not the simplest of solutions, but it's the only way I can think of to have it working as expected in all cases.

I thought I'd get your opinion before going ahead and making these changes. Let me know what you think.

colbysargentcodes avatar Apr 13 '17 20:04 colbysargentcodes