File tree Expand file tree Collapse file tree 3 files changed +18
-11
lines changed Expand file tree Collapse file tree 3 files changed +18
-11
lines changed Original file line number Diff line number Diff line change 33 "description" : " Yet another Vue treeview component." ,
44 "author" : " Gregg Rapoza <grapoza@gmail.com>" ,
55 "license" : " MIT" ,
6- "version" : " 1.3.6 " ,
6+ "version" : " 1.3.7 " ,
77 "browser" : " index.js" ,
88 "repository" : {
99 "url" : " https://github.com/grapoza/vue-tree" ,
Original file line number Diff line number Diff line change @@ -69,15 +69,22 @@ export default {
6969 if ( firstSelectedNode === null && this . focusableNodeModel . selectable && this . selectionMode === 'selectionFollowsFocus' ) {
7070 this . focusableNodeModel . state . selected = true ;
7171 }
72+
73+ this . $_treeViewNode_enforceSelectionMode ( ) ;
7274 }
7375 } ,
7476 watch : {
75- selectionMode ( newValue ) {
76- if ( newValue === 'single' ) {
77+ selectionMode ( ) {
78+ this . $_treeViewNode_enforceSelectionMode ( ) ;
79+ }
80+ } ,
81+ methods : {
82+ $_treeViewNode_enforceSelectionMode ( ) {
83+ if ( this . selectionMode === 'single' ) {
7784 // This is in TreeViewAria instead of TreeView because the default mixin merge strategy only keeps one 'watch' per prop.
7885 this . $_treeView_enforceSingleSelectionMode ( ) ;
7986 }
80- else if ( newValue === 'selectionFollowsFocus' ) {
87+ else if ( this . selectionMode === 'selectionFollowsFocus' ) {
8188 // Make sure the actual focused item is selected if the mode changes, and deselect all others
8289 this . $_treeView_depthFirstTraverse ( ( node ) => {
8390 let idPropName = this . $_treeView_getIdPropName ( node ) ;
@@ -92,9 +99,7 @@ export default {
9299 }
93100 } ) ;
94101 }
95- }
96- } ,
97- methods : {
102+ } ,
98103 $_treeViewAria_handleFocusableChange ( newNodeModel ) {
99104 if ( this . focusableNodeModel ) {
100105 this . focusableNodeModel . focusable = false ;
Original file line number Diff line number Diff line change @@ -156,8 +156,9 @@ export default {
156156 }
157157 else {
158158 let lastModel = this . model [ this . childrenPropName ] [ childIndex - 1 ] ;
159- while ( lastModel . children . length > 0 && lastModel . expandable && lastModel . state . expanded ) {
160- lastModel = lastModel [ this . $_treeViewNode_getChildrenPropNameForNode ( lastModel ) ] [ lastModel . children . length - 1 ] ;
159+ let lastModelChildren = lastModel [ this . $_treeViewNode_getChildrenPropNameForNode ( lastModel ) ] ;
160+ while ( lastModelChildren . length > 0 && lastModel . expandable && lastModel . state . expanded ) {
161+ lastModel = lastModelChildren [ lastModelChildren . length - 1 ] ;
161162 }
162163
163164 lastModel . focusable = true ;
@@ -168,8 +169,9 @@ export default {
168169 // If the node has a next sibling, focus that
169170 // Otherwise, punt this up to this node's parent
170171 let childIndex = this . model [ this . childrenPropName ] . indexOf ( childNode ) ;
171- if ( ! ignoreChild && childNode . children . length > 0 && childNode . expandable && childNode . state . expanded ) {
172- childNode [ this . $_treeViewNode_getChildrenPropNameForNode ( childNode ) ] [ 0 ] . focusable = true ;
172+ let childNodeChildrenPropName = this . $_treeViewNode_getChildrenPropNameForNode ( childNode ) ;
173+ if ( ! ignoreChild && childNode [ childNodeChildrenPropName ] . length > 0 && childNode . expandable && childNode . state . expanded ) {
174+ childNode [ childNodeChildrenPropName ] [ 0 ] . focusable = true ;
173175 }
174176 else if ( childIndex < this . model [ this . childrenPropName ] . length - 1 ) {
175177 this . model [ this . childrenPropName ] [ childIndex + 1 ] . focusable = true ;
You can’t perform that action at this time.
0 commit comments