DevExpress / DevExtreme

HTML5 JavaScript Component Suite for Responsive Web Development
https://js.devexpress.com/
Other
1.81k stars 596 forks source link

Element attributes do not get applied the first time a dxo-filter-builder-popup is opened #13488

Closed clairross-hyperview closed 4 years ago

clairross-hyperview commented 4 years ago

Steps to Reproduce:

  1. Use this demo: https://js.devexpress.com/Demos/WidgetsGallery/Demo/DataGrid/FilterPanel/Angular/Light/
  2. Replace the existing dxo-filter-builder-popup with
    <dxo-filter-builder-popup
    [elementAttr]="{class: 'this-should-exist'}"
        [position]="popupPosition">
    </dxo-filter-builder-popup>
  3. Hit Apply
  4. In the demo, click on [Employee] Equals 'Clark Morgan' And [Order Date] Weekends
  5. Open the inspector (hit F12)
  6. Search for 'this-should-exist'. Note there is 2 so far (the text entered and the one near the button clicked in step 4.)
  7. Close the modal and repeat steps 4-6 and note there is now a third instance of 'this-should-exist', the one expected to exist before.

Results You Received:

First time opening the Filter Builder modal does not apply the elementAttr as expected to the modal itself.

Results You Expected:

The elementAttr should be applied on the first time the modal is opened, similar to the second time it is opened.

Environment Details:

Browser: Chrome - Version 83.0.4103.106 (Official Build) (64-bit) OS: Microsoft Windows 10 Pro (Version 10.0.18363 Build 18363) npm:

NickMitrokhin commented 4 years ago

Hi,

Our Popup widget does not allow specifying CSS class using the elementAttr option. That is why, your scenario does not operate properly. We are going to improve this behavior in future versions.

Meanwhile, you can achieve your goal using the following code in the DataGrid.onContentReady event handler as shown below:

onContentReady(e: any) {
   //__isReady is a fake option for preventing from code execution 
   //each time the onContentReady is called
   if(!e.component.__isReady) { 
       e.component.__isReady = true;
       e.component.getView('filterBuilderView').element()[0].classList.add('this-should-exist');
    }
}

Note that this approach uses an undocumented API that may not work in future versions.