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

Color picker window toggles #70

Open
zea726 opened this issue May 6, 2015 · 3 comments
Open

Color picker window toggles #70

zea726 opened this issue May 6, 2015 · 3 comments

Comments

@zea726
Copy link

zea726 commented May 6, 2015

Hi,

I was trying to use the color picker for the input box. If you press on input box the color palate will appear but as soon as you click on the tab like advance its just disappearing. Is it a bug or you did it intentionally.

Pleas let me know how can I solve this.

Regards
Zea

@alanhartless
Copy link

I had the same issue which I solved by changing these lines around https://github.com/lauren/pick-a-color/blob/master/src/js/pick-a-color.js#L1001-L1013

            // Prevent blur from not applying color selection
            var menuClicked = false;
            myElements.colorMenu.on(startEvent, function (e) {
                menuClicked = true;
            });

            myElements.thisEl.focus(function () {
                var $thisEl = $(this);
                myColorVars.typedColor = $thisEl.val(); // update with the current
                if (!settings.allowBlank) {
                    $thisEl.val(""); //clear the field on focus
                }
                methods.toggleDropdown(myElements.colorPreviewButton, myElements.ColorMenu);
            }).blur(function (event) {
                if (menuClicked) {
                    menuClicked = false;
                    return false;
                }

@zea726
Copy link
Author

zea726 commented May 26, 2015

Thank you.

Yes it worked for the click function but if you click on tabs (advance, saved) and click outside without changing any value the previous value just disappeared or empty.

Regards
Zea

@zea726
Copy link
Author

zea726 commented May 26, 2015

I just modify this... may be you also meant this but I did'nt get at first glance

myElements.thisEl.focus(function () {
          var $thisEl = $(this);
          myColorVars.typedColor = $thisEl.val(); // update with the current
          if (!settings.allowBlank) {
            $thisEl.val(""); //clear the field on focus
          }
          methods.toggleDropdown(myElements.colorPreviewButton,myElements.ColorMenu);
        }).blur(function (event) {
            var $thisEl = $(this);
            myColorVars.newValue = $thisEl.val(); // on blur, check the field's value
            // if the field is empty, put the original value back in the field
            if (menuClicked) {
                menuClicked = false;
                if (myColorVars.newValue.match(/^\s+$|^$/)) {
                    if (!settings.allowBlank) {
                        $thisEl.val(myColorVars.typedColor);
                    }
                }
                return false;
            }

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

No branches or pull requests

2 participants