When I load the edit tab for my node type, the last phone field on the page grabs focus. In my case, because the phone fields are so far down the page, this means my edit tab loads showing the middle of the form.

I expected that my edit tabs would open as normal, rather than scrolled halfway down.

I am working on a patch, but I'm not a JS wizard, so I'd love some help if you can give it. Thanks!

Comments

ezheidtmann’s picture

This patch solves the problem in Chromium, with no negative effect that I found.

It should be tested in other browsers.

ezheidtmann’s picture

Previous patch breaks editing in the middle of the number in Firefox. Bummertown.

ezheidtmann’s picture

This works in Firefox & Chromium. Testing in IE ...

ezheidtmann’s picture

Status: Active » Needs review

The latest patch solves the original issue in Firefox & Chromium, while maintaining all other editing features. In IE, it has no effect. Can you please review? Thanks!

NealB-1’s picture

I have been swamped with work, and my development virtual machine crashed, so I can't test a fix. I looked at the repository through drupal.org, and I looked at your patch.

I think the problem is simply this. This is the code that executes on page load:

     $('.nice-phone-number-input', context).each(function() {
       // update the number input field
       var text = $(this).val();
       var number = text.replace(/[^0-9]/g, '');

       var textInfo = { number: number, numberPos: null, cursor: 0 };

       rebuildPhoneNumberTextField(this, textInfo);
     });

cursor should be getting set to null instead of zero, because zero is an actual cursor position, and triggers the conditional you were trying to fix:

       var textInfo = { number: number, numberPos: null, cursor: null };

I may have broken it when I refactored, but I'm glad I did. That javascript used to be a lot scarier to look at.

ezheidtmann’s picture

Nice job, Neal. Tested successfully in Chrome, FF, and IE. Attached is the patch I'm using.

NealB-1’s picture

Assigned: ezheidtmann » NealB-1
Status: Needs review » Closed (fixed)

Thanks.