Opened 5 years ago

Last modified 5 years ago

#17451 new defect

ComboBoxMixin and _FormSelectWidget patch their store and break each other.

Reported by: qMax Owned by:
Priority: undecided Milestone: 2.0
Component: Dijit - Form Version: 1.9.1
Keywords: Cc:
Blocked By: Blocking:

Description

When new style store is passed as parameter to ComboBoxMixin?, it modifies its store and adds methods getValue, getLabel, fetch to produce deprication warnings (in postMixInProperties()).

Now if the same store is used in other Select-based widgets, the _FormSelectWidget threats it like old-api and tries to use nonexistant methods. (in setStore()) Also, it patches the store again to make it look like new-style api. (also in setStore())

Why on earth should widget patch data store api?

P.S. workaround is to use set('store') everywhere.

Attachments (1)

main.js (827 bytes) - added by qmax 5 years ago.
Uncaught TypeError?: Object [object Object] /* the store */ has no method 'getLabelAttributes' dijit/form/_FormSelectWidget.js:332

Download all attachments as: .zip

Change History (4)

comment:1 Changed 5 years ago by bill

Owner: set to qMax
Status: newpending

When new style store is passed as parameter to ComboBoxMixin?, it modifies its store and adds methods getValue, getLabel, fetch to produce deprication warnings (in postMixInProperties()).

I don't think so. The code that adds those methods in postMixInProperties() only runs when ComboBox? creates a store internally. Notice the first clause of the if() statement:

if(!this.params.store && !this.store._oldAPI){

Why on earth should widget patch data store api?

As the comment in the code says:

// User may try to access this.store.getValue() etc.  in a custom labelFunc() function.
// It's not available with the new data store for handling inline <option> tags, so add it.

Anyway, there may be some issue, but please attach a full (but minimal) test case (using the attach file button) that demonstrates the issue.

Changed 5 years ago by qmax

Attachment: main.js added

Uncaught TypeError?: Object [object Object] /* the store */ has no method 'getLabelAttributes' dijit/form/_FormSelectWidget.js:332

comment:2 Changed 5 years ago by qmax

When Combo is created this way:

    var myCombo = declare([ComboBox], {
        store: store,
        searchAttr: 'label'
    });

The store is not in params and became patched.

In attached file an error only occurs if Combo is created before Select. No error when in opposite order.

comment:3 Changed 5 years ago by bill

Milestone: tbd2.0
Owner: qMax deleted
Status: pendingnew

Ah yes that case doesn't work correctly. The patching code should probably be more particular, and only patch the dijit/form/DataList store. But anyway this problem will fix itself in V2 when all the back-compat code goes away.

Last edited 5 years ago by bill (previous) (diff)
Note: See TracTickets for help on using tickets.