Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restrict the typed value to an option in the hidden dropdown on blur #24

Closed
wants to merge 3 commits into from

Conversation

dontangg
Copy link
Contributor

@dontangg dontangg commented Dec 9, 2011

There are 3 commits in this pull request. I'll try to explain a little about each:

Changed all tabs to 2 spaces
This commit only fixes whitespace formatting. I noticed that 2 spaces were used in most cases. So, I switched all tabs to 2 spaces. Specifically, this makes it a lot nicer to look at on GitHub.com.

Revert to previously selected value when the field loses focus and has an invalid value
This is the main reason for these commits. If you accept this pull request, this table describes the behavior:

ActionBehavior
Type a partial match, then hit enter or tabThe full value matching your partial is inserted
Type a partial match and click somewhere other than the suggestions and text fieldThe previous valid value is inserted
Type a partial match, then hit escape to hide the suggestions, then hit enter or tab without typing anything elseThe previous valid value is inserted
Type a completely invalid value and leave the field in any wayThe previous valid value is inserted

When I say, "The previous valid value is inserted," I mean that the currently selected option from the hidden dropdown is inserted.

Fixed bug where 'copy-attributes-to-text-field': false caused the text field to never be inserted into the dom
While working on this, I noticed that the statements that actually add the text field to the DOM were inside the if statement that only executes when copy-attributes-to-text-field is true. So, I tested it and sure enough, the text field never appears on the page if that setting is set to false. Normally, I would put this in as a separate pull request, but since it affects the same lines of code, I thought this would be easier.

I am very willing to make tweaks or discuss this further if you have questions! Let me know. This addresses issue #16.

@jamieholst
Copy link
Owner

Hello Mr. Wilson,

I really like the idea behind these commits, but I think there's a few modifications that should be made before merging them into the plugin. Let me address each commit below:

Changed all tabs to 2 spaces
Makes sense. Cheers!

Revert to previously selected value when the field loses focus and has an invalid value
I like this behavior, but right now there's a "handle_invalid_input" function which handles invalid input. The code should go in this function so people can overwrite the behavior if needed.

Fixed bug where 'copy-attributes-to-text-field': false caused the text field to never be inserted into the dom
Fixed.

@dontangg
Copy link
Contributor Author

This pull request is made obsolete by #25.

@dontangg dontangg closed this Dec 14, 2011
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.

2 participants