mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 21:40:39 +03:00
Fixed Firefox not respecting default selected operator when changing filter type
no issue - if `<option>` elements are re-rendered without the parent `<select>` being re-rendered, Firefox does not pick up the new `selected` option - we were seeing this behaviour when the options in an operator select get updated after changing the filter type, Firefox was always selecting the first option rather than the "selected" option - switched the `filters` array from an EmberArray instance over to a tracked built in Array instance and changed the "edit" behaviour when changing a filter type so we fully replace a `Filter` instance in the filters array with a new instance which causes an overall re-render of that filter row avoiding the Firefox issue
This commit is contained in:
parent
b392bdfc0e
commit
bee16a023d
@ -2,6 +2,7 @@ import Component from '@glimmer/component';
|
|||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import nql from '@nexes/nql-lang';
|
import nql from '@nexes/nql-lang';
|
||||||
import {A} from '@ember/array';
|
import {A} from '@ember/array';
|
||||||
|
import {TrackedArray} from 'tracked-built-ins';
|
||||||
import {action} from '@ember/object';
|
import {action} from '@ember/object';
|
||||||
import {inject as service} from '@ember/service';
|
import {inject as service} from '@ember/service';
|
||||||
import {task} from 'ember-concurrency';
|
import {task} from 'ember-concurrency';
|
||||||
@ -168,7 +169,7 @@ export default class MembersFilter extends Component {
|
|||||||
@service settings;
|
@service settings;
|
||||||
@service store;
|
@service store;
|
||||||
|
|
||||||
@tracked filters = A([
|
@tracked filters = new TrackedArray([
|
||||||
new Filter({
|
new Filter({
|
||||||
id: `filter-0`,
|
id: `filter-0`,
|
||||||
type: 'label',
|
type: 'label',
|
||||||
@ -224,7 +225,7 @@ export default class MembersFilter extends Component {
|
|||||||
|
|
||||||
@action
|
@action
|
||||||
addFilter() {
|
addFilter() {
|
||||||
this.filters.pushObject(new Filter({
|
this.filters.push(new Filter({
|
||||||
id: `filter-${this.nextFilterId}`,
|
id: `filter-${this.nextFilterId}`,
|
||||||
type: 'label',
|
type: 'label',
|
||||||
relation: 'is',
|
relation: 'is',
|
||||||
@ -440,7 +441,7 @@ export default class MembersFilter extends Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.filters = A(filterData);
|
this.filters = new TrackedArray(filterData);
|
||||||
}
|
}
|
||||||
|
|
||||||
getFilterRelationOperator(relation) {
|
getFilterRelationOperator(relation) {
|
||||||
@ -459,11 +460,10 @@ export default class MembersFilter extends Component {
|
|||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
const filterToDelete = this.filters.findBy('id', filterId);
|
|
||||||
if (this.filters.length === 1) {
|
if (this.filters.length === 1) {
|
||||||
this.resetFilter();
|
this.resetFilter();
|
||||||
} else {
|
} else {
|
||||||
this.filters.removeObject(filterToDelete);
|
this.filters = new TrackedArray(this.filters.reject(f => f.id === filterId));
|
||||||
this.applySoftFilter();
|
this.applySoftFilter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -499,13 +499,17 @@ export default class MembersFilter extends Component {
|
|||||||
defaultRelation = 'is-or-less';
|
defaultRelation = 'is-or-less';
|
||||||
}
|
}
|
||||||
|
|
||||||
const filterToEdit = this.filters.findBy('id', filterId);
|
const newFilter = new Filter({
|
||||||
if (filterToEdit) {
|
id: filterId,
|
||||||
filterToEdit.type = newType;
|
type: newType,
|
||||||
filterToEdit.relationOptions = this.availableFilterRelationsOptions[newType];
|
relation: defaultRelation,
|
||||||
filterToEdit.relation = defaultRelation;
|
relationOptions: this.availableFilterRelationsOptions[newType],
|
||||||
filterToEdit.value = defaultValue;
|
value: defaultValue,
|
||||||
}
|
timezone: this.settings.get('timezone')
|
||||||
|
});
|
||||||
|
|
||||||
|
const filterToSwap = this.filters.find(f => f.id === filterId);
|
||||||
|
this.filters[this.filters.indexOf(filterToSwap)] = newFilter;
|
||||||
|
|
||||||
if (newType !== 'label' && defaultValue) {
|
if (newType !== 'label' && defaultValue) {
|
||||||
this.applySoftFilter();
|
this.applySoftFilter();
|
||||||
@ -518,14 +522,14 @@ export default class MembersFilter extends Component {
|
|||||||
|
|
||||||
@action
|
@action
|
||||||
setFilterRelation(filterId, newRelation) {
|
setFilterRelation(filterId, newRelation) {
|
||||||
const filterToEdit = this.filters.findBy('id', filterId);
|
const filterToEdit = this.filters.find(f => f.id === filterId);
|
||||||
filterToEdit.relation = newRelation;
|
filterToEdit.relation = newRelation;
|
||||||
this.applySoftFilter();
|
this.applySoftFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
setFilterValue(filterType, filterId, filterValue) {
|
setFilterValue(filterType, filterId, filterValue) {
|
||||||
const filterToEdit = this.filters.findBy('id', filterId);
|
const filterToEdit = this.filters.find(f => f.id === filterId);
|
||||||
filterToEdit.value = filterValue;
|
filterToEdit.value = filterValue;
|
||||||
this.applySoftFilter();
|
this.applySoftFilter();
|
||||||
}
|
}
|
||||||
@ -561,7 +565,7 @@ export default class MembersFilter extends Component {
|
|||||||
@action
|
@action
|
||||||
resetFilter() {
|
resetFilter() {
|
||||||
this.nextFilterId = 1;
|
this.nextFilterId = 1;
|
||||||
this.filters = A([
|
this.filters = new TrackedArray([
|
||||||
new Filter({
|
new Filter({
|
||||||
id: `filter-0`,
|
id: `filter-0`,
|
||||||
type: 'label',
|
type: 'label',
|
||||||
|
Loading…
Reference in New Issue
Block a user