Skip to content

Commit

Permalink
Add sorting to types in schemawidget.
Browse files Browse the repository at this point in the history
  • Loading branch information
robgietema committed Dec 17, 2024
1 parent f3c4b4d commit 2f993ce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1738,6 +1738,7 @@ class SchemaWidget extends Component {
},
filterChoices: filterFactory,
additionalChoices: additionalFactory,
sort: true,
},
},
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { compose } from 'redux';
import { filter, map } from 'lodash';
import { filter, map, sortBy } from 'lodash';
import { defineMessages, injectIntl } from 'react-intl';
import {
getVocabFromHint,
Expand Down Expand Up @@ -122,6 +122,7 @@ class SelectWidget extends Component {
customOptionStyling: PropTypes.any,
isMulti: PropTypes.bool,
placeholder: PropTypes.string,
sort: PropTypes.bool,
};

/**
Expand Down Expand Up @@ -149,6 +150,7 @@ class SelectWidget extends Component {
onDelete: null,
noValueOption: true,
customOptionStyling: null,
sort: false,
};

/**
Expand Down Expand Up @@ -240,6 +242,10 @@ class SelectWidget extends Component {
options = filter(options, (item) => filterChoices.includes(item.value));
}

if (this.props.sort) {
options = sortBy(options, ['label']);
}

const normalizedValue = normalizeValue(options, value, intl);

const isMulti = this.props.isMulti
Expand Down

0 comments on commit 2f993ce

Please sign in to comment.