Skip to content

Commit

Permalink
Fixes for constraint selection.
Browse files Browse the repository at this point in the history
- Don't error when constraints are cleared while selection is active.
- Don't show "latest" highlight when it is the current selection.
  • Loading branch information
sigh committed Oct 28, 2024
1 parent 670fb13 commit a36caf8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,8 @@ <h2>Composite constraints (experimental)</h2>
<div>
<span class="description">
Select a composite constraint by clicking on its chip to
add constraints to it.
add constraints to it. Panels which allow constraints to be
added to the composite will be highlighted in yellow.
</span>
<button type="button" name="add-or" title="Add 'Or'">
+ Or
Expand Down
12 changes: 6 additions & 6 deletions js/constraint_displays.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class BaseConstraintDisplayItem extends DisplayItem {
}

removeItem(item) {
item.parentNode.removeChild(item);
item.parentNode?.removeChild(item);
}

_removeCircleFromPath(p0, p1) {
Expand Down Expand Up @@ -285,7 +285,7 @@ ConstraintDisplays.Jigsaw = class Jigsaw extends BaseConstraintDisplayItem {
removeItem(item) {
if (this._regionElems.has(item)) {
this._colorPicker.removeItem(item);
item.parentNode.removeChild(item);
item.parentNode?.removeChild(item);
this._regionElems.delete(item);
this._updateMissingRegion();
}
Expand Down Expand Up @@ -417,7 +417,7 @@ ConstraintDisplays.CustomBinary = class CustomBinary extends ConstraintDisplays.

removeItem(item) {
if (this._colorPicker.removeItem(item)) {
item.parentNode.removeChild(item);
item.parentNode?.removeChild(item);
}
}

Expand Down Expand Up @@ -606,7 +606,7 @@ ConstraintDisplays.ShadedRegion = class ShadedRegion extends BaseConstraintDispl

removeItem(item) {
if (this._cellColors.removeItem(item)) {
item.parentNode.removeChild(item);
item.parentNode?.removeChild(item);
}
}

Expand Down Expand Up @@ -734,7 +734,7 @@ ConstraintDisplays.CountingCircles = class CountingCircles extends BaseConstrain

removeItem(item) {
if (this._circleColors.removeItem(item)) {
item.parentNode.removeChild(item);
item.parentNode?.removeChild(item);
}
}

Expand Down Expand Up @@ -945,7 +945,7 @@ ConstraintDisplays.BorderedRegion = class BorderedRegion extends BaseConstraintD

removeItem(item) {
if (this._colorPicker.removeItem(item)) {
item.parentNode.removeChild(item);
item.parentNode?.removeChild(item);
}
}

Expand Down
4 changes: 3 additions & 1 deletion js/render_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -1527,7 +1527,9 @@ class ConstraintSelector {
}

updateLatest(constraint, chip) {
this._latestHighlighter.setConstraint(constraint, chip);
if (constraint !== this._selectionHighlighter.currentConstraint()) {
this._latestHighlighter.setConstraint(constraint, chip);
}
}

select(constraint, chip, collection) {
Expand Down

0 comments on commit a36caf8

Please sign in to comment.