From a7d1566e232cc78ae34be4846c3497b2de6a3ec6 Mon Sep 17 00:00:00 2001 From: Reborn Date: Mon, 28 Mar 2022 18:37:32 +0800 Subject: [PATCH] Fixed JFXChipView can not be scrolled when chip filled one*n row (it called updateEditorPosition() at any time before) --- .../src/main/java/com/jfoenix/skins/JFXChipViewSkin.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/jfoenix/src/main/java/com/jfoenix/skins/JFXChipViewSkin.java b/jfoenix/src/main/java/com/jfoenix/skins/JFXChipViewSkin.java index 4dfeeb229..88738cc68 100644 --- a/jfoenix/src/main/java/com/jfoenix/skins/JFXChipViewSkin.java +++ b/jfoenix/src/main/java/com/jfoenix/skins/JFXChipViewSkin.java @@ -50,6 +50,7 @@ import javafx.util.StringConverter; import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; /** * JFXChipArea is the material design implementation of chip Input. @@ -73,6 +74,7 @@ public class JFXChipViewSkin extends SkinBase> { private boolean editorOnNewLine = true; private double availableWidth; private double requiredWidth; + private final AtomicInteger mMangedChildrenSize = new AtomicInteger(0); private final ListChangeListener chipsChangeListeners = change -> { while (change.next()) { @@ -135,7 +137,7 @@ public void requestFocus() { createChip(item); } control.getChips().addListener(new WeakListChangeListener<>(chipsChangeListeners)); - + } @Override @@ -223,7 +225,7 @@ private void setupEditor() { autoCompletePopup.show(editor); } }); - + editor.promptTextProperty().bind(control.promptTextProperty()); root.getChildren().add(editor); @@ -338,6 +340,8 @@ public void updateEditorPosition() { final List managedChildren = getManagedChildren(); final int mangedChildrenSize = managedChildren.size(); if (mangedChildrenSize > 0) { + if (mMangedChildrenSize.get() == mangedChildrenSize) return; + mMangedChildrenSize.set(mangedChildrenSize); Region lastChild = (Region) managedChildren.get(mangedChildrenSize - 1); double contentHeight = lastChild.getHeight() + lastChild.getLayoutY(); availableWidth = insideWidth - lastChild.getBoundsInParent().getMaxX();