laptop and a wrench

Bug

The layers order within the Legend is not updated if the order of the layers on the map is changed.

Last Published: April 6, 2020 ArcGIS API for JavaScript
Bug ID Number BUG-000127418
SubmittedDecember 16, 2019
Last ModifiedJuly 20, 2025
Applies toArcGIS API for JavaScript
Version found4.13
Operating SystemWindows OS
Operating System Version10.0 64 Bit
Version Fixed4.15
StatusFixed

Workaround

Add the additional code to reflect the changes within the Legend.

Uncomment line 39-58 in the codepen sample to see the changes:

 

if(true){

     

     LegendViewModel.prototype._addActiveLayerInfo = function(e, t) {

       if (this._isLayerActive(t) && -1 === this.activeLayerInfos.indexOf(e)) {

         var r = e.parent;

          

         if(r){ 

          if(-1 === r.children.indexOf(e)){

           r.children.push(e)

          };

          this._sortActiveLayerInfos(r.children)

         }else{ 

          this.activeLayerInfos.add(e);

          this._sortActiveLayerInfos(this.activeLayerInfos);

         }

       }

     }

    }

Steps to Reproduce

Bug ID: BUG-000127418

Software:

  • ArcGIS API for JavaScript

Get notified when the status of a bug changes

Download the Esri Support App

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options