modxcms / a11y

MODX Accessibility for the Manager
13 stars 10 forks source link

Focus on editing pane, instead of reading tree menu when editing from keyboard #10

Closed rthrash closed 8 years ago

rthrash commented 9 years ago

When you edit a page from keyboard, it stays focused on the tree menu. Where should this focus/start reading?

paulbohman commented 9 years ago

If you mean when you click on a page in the tree, the focus stays in the tree, I think it depends on which browser you use. When I use Chrome, the focus seems to go to the pagetitle field at first, but when the tree finishes loading, the focus goes to the tree. When I use Firefox, the focus seems to stay on pagetitle, which is better.

dubrod commented 9 years ago

I tried to find the JS file that was causing it to focus the tree. I even added some JS to our custom INIT function but no luck. Maybe @rtripault can find it.

rtripault commented 9 years ago

@dubrod commenting/removing :

Should do the trick

paulbohman commented 9 years ago

We'll have to be careful, though, that we don't disable tree focus under all circumstances. If I'm in the tree and I expand a node, I want the focus to remain on the tree on that node, right? The problem is when the tree self-expands to match the most recent state after I do an action like save a page. When I'm saving a page or doing other things in the main pane, I want the focus to remain in that pane, rather than jump to the tree.

It's a matter of keeping track of where the user is and what actions are being performed, and then assigning the focus appropriately based on those parameters.

rtripault commented 9 years ago

Definitely. The code lines mentioned in my previous message are supposed to only be executed when the trees are loaded. I guess they were here only to visually indicate a selection.

Hitting the save button indeed seems to remove the focus from the "button bar". I'll try to find the source.

dubrod commented 9 years ago

Ok if save while editing it keeps focus where you are. On reload/new resource it while focus Page title

dubrod commented 9 years ago

After much discussion with the core team we are going to avoid editing the core files at this time. This feature however is being considered for the next release.

@TheBoxer and I have already detailed what it takes to make this issue work and I'll detail it here for documentation sake:

modext/widgets/resource/modx.panel.resource.js

,onFieldChange: function(o) {
        //a11y - Set Active Input
        if(o){
            Ext.state.Manager.set("curFocus", o.field.id);
        }    

    }

assets/modext/widgets/core/modx.panel.js

Line 100: ,success: function(f,a) {

after this.fireEvent('setup',this.config);

var lastActiveEle = Ext.state.Manager.get("curFocus");
var initFocus = document.getElementById(lastActiveEle);
if(initFocus) initFocus.focus();

widgets/core/tree/modx.tree.js

Around line 147 ,onLoad the following needs taken out

Ext.each(node.childNodes, function(node){
      if (node.attributes.selected) {
      node.select();
}

Around line 219 this.root.firstChild.select(); also needs to be taken out

dubrod commented 8 years ago

This was added to 2.4 and is now active