@@ -70,10 +70,14 @@ function markerSelectUpdater(state, action) {
70
70
const { field, values} = action . payload ;
71
71
const visState = visStateSelector ( state ) ;
72
72
let currentFilterIdx = visState . filters . findIndex ( f => f . name === field && f . dataId === DATA_ID && f . tableauMarkerFilter ) ;
73
-
74
73
let nextState = visState ;
75
74
if ( values . length ) {
76
75
if ( currentFilterIdx < 0 ) {
76
+ const filterField = getFilterField ( visState , field ) ;
77
+ if ( ! filterField ) {
78
+ // field not in visState
79
+ return state ;
80
+ }
77
81
log ( 'add filter based on marker' )
78
82
// add filter
79
83
nextState = visStateUpdaters . addFilterUpdater ( nextState , { dataId : DATA_ID } ) ;
@@ -85,7 +89,7 @@ function markerSelectUpdater(state, action) {
85
89
nextState = visStateUpdaters . setFilterUpdater ( nextState , { idx, prop : 'dataId' , value : DATA_ID } ) ;
86
90
87
91
// set filter name and props
88
- const newFilter = getNewFilter ( nextState , idx , field ) ;
92
+ const newFilter = getNewFilter ( nextState , idx , filterField ) ;
89
93
nextState = {
90
94
...nextState ,
91
95
filters : nextState . filters . map ( ( f , i ) => i === idx ? newFilter : f )
@@ -97,7 +101,7 @@ function markerSelectUpdater(state, action) {
97
101
nextState = visStateUpdaters . setFilterUpdater ( nextState , { idx : currentFilterIdx , prop : 'value' , value : values } ) ;
98
102
} else if ( currentFilterIdx >= 0 ) {
99
103
// remove filter
100
- log ( 'remove gilter based on marker' )
104
+ log ( 'remove filter based on marker' )
101
105
nextState = visStateUpdaters . removeFilterUpdater ( nextState , { idx : currentFilterIdx } ) ;
102
106
}
103
107
@@ -119,24 +123,24 @@ function updateKeplerGlState(state, newState) {
119
123
}
120
124
121
125
function getNewFilter ( state , idx , field ) {
122
- const filterField = getFilterField ( state , field ) ;
123
- const fieldIdx = filterField . tableFieldIndex - 1 ;
126
+ const fieldIdx = field . tableFieldIndex - 1 ;
124
127
const values = state . datasets [ DATA_ID ] . allData . map ( row => row [ fieldIdx ] ) ;
125
128
126
129
const filterProp = {
127
130
domain : unique ( values ) . sort ( ) ,
128
- fieldType : filterField . type ,
131
+ fieldType : field . type ,
129
132
type : 'multiSelect' ,
130
133
value : [ ]
131
134
} ;
132
135
133
136
const newFilter = {
134
137
...state . filters [ idx ] ,
135
138
...filterProp ,
136
- name : field ,
139
+ name : field . name ,
137
140
// can't edit dataId once name is selected
138
141
freeze : true ,
139
142
fieldIdx,
143
+ // add tableau identifier to filter
140
144
tableauMarkerFilter : true
141
145
} ;
142
146
0 commit comments