File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
vcf-input-mask/src/main/java/com/vaadin/componentfactory/addons/inputmask Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 2323import com .vaadin .flow .component .UI ;
2424import com .vaadin .flow .component .dependency .JsModule ;
2525import com .vaadin .flow .component .dependency .NpmPackage ;
26+ import com .vaadin .flow .dom .Element ;
2627import com .vaadin .flow .function .SerializableConsumer ;
2728import com .vaadin .flow .shared .Registration ;
2829import java .lang .ref .WeakReference ;
@@ -74,7 +75,13 @@ private void extend(Component component, UI ui) {
7475 getElement ().setProperty ("options" , objectMapper .writeValueAsString (options ));
7576
7677 extended = new WeakReference <Component >(component );
77- component .getElement ().appendChild (getElement ());
78+
79+ Element componentElement = component .getElement ();
80+ // remove any existing input-mask element attached to component
81+ componentElement .getChildren ()
82+ .filter (child -> TAG_NAME .equalsIgnoreCase (child .getTag ()))
83+ .findAny ().ifPresent (componentElement ::removeChild );
84+ componentElement .appendChild (getElement ());
7885
7986 if (HasValue .class .isAssignableFrom (component .getClass ())) {
8087 valueChangeRegistration = HasValue .class .cast (component ).addValueChangeListener (e -> {
You can’t perform that action at this time.
0 commit comments