I am attempting to display two new buttons after clicking the first one. To do this I have the two buttons I want to display set to display: none
. When the initial button is clicked it toggles its display to none and then displays the other two buttons as display: block
.
This works but a weird display bug occurs where initially the buttons are much larger than they should be, and quickly return to the size they are supposed to be.
I've attached images to show this, but could not embed because my reputation.
HTML
<div class = "container">
<div class = "row p-0">
<div class = "col text-field-wrapper m-0 p-0"></div>
<div class = "col button-field-wrapper"></div>
</div>
</div>
CSS:
.button-field-wrapper {
font-size: 12px;
margin: 18px 0 0 0;
height: 36px;
display: block;
}
.hide {
display: none
}
.text-field-wrapper: {
height: 56px;
display: block;
}
JavaScript:
constructor() {
super();
this.active = false;
this.default = true;
this.maxWidth = 200;
this.error = false;
this.overflow = false;
this.getWidth();
this.inputText = "Enter A Title";
this.appendChild(template.content.cloneNode(true));
this.tf_wrapper = this.getElementsByClassName("text-field-wrapper")[0];
this.bt_wrapper = this.getElementsByClassName("button-field-wrapper")[0];
this.renderInputField.bind(this)(this.tf_wrapper);
this.renderButtonField.bind(this)(this.bt_wrapper);
this.renderOptionField.bind(this)(this.bt_wrapper);
this.optionWrapper.setAttribute("class", "hide", "option-wrapper")
}
renderOptionField(bt_wrapper) {
this.optionWrapper = document.createElement("DIV");
this.optionWrapper.setAttribute("class", "option-wrapper");
bt_wrapper.appendChild(this.optionWrapper);
this.cancelButton = document.createElement("Button");
this.cancelButton.setAttribute("class", "cancel-button");
this.cancelButton.addEventListener("click",
this.onCancel.bind(this))
this.closeIcon = document.createElement("object");
this.closeIcon.setAttribute("type", "image/svg+xml");
this.closeIcon.setAttribute("class", "close-icon");
this.closeIcon.setAttribute("data", "Close.svg")
this.cancelButton.appendChild(this.closeIcon)
this.cancelButton.innerHTML += "Cancel";
this.saveButton = document.createElement("Button");
this.saveButton.setAttribute("class", "save-button");
this.saveButton.addEventListener("click", this.onSave.bind(this))
this.saveIcon = document.createElement("object");
this.saveIcon.setAttribute("type", "image/svg+xml");
this.saveIcon.setAttribute("class", "save-icon");
this.saveIcon.setAttribute("data", "Check.svg")
this.saveButton.appendChild(this.saveIcon)
this.saveButton.innerHTML += "Save";
this.optionWrapper.appendChild(this.cancelButton);
this.optionWrapper.appendChild(this.saveButton);
}
onEdit() {
this.editWrapper.setAttribute("class", "edit-wrapper hide")
this.optionWrapper.setAttribute("class", "option-wrapper")
this.textField.setAttribute("class", "text-field-active single-
line")
this.active = true;
}