Skip to content

Commit

Permalink
fix(input): clear button showing up when disabled (#368)
Browse files Browse the repository at this point in the history
Avoid focus and blur events to be emitted while disabled.
  • Loading branch information
dgonzalezr committed Jul 20, 2023
1 parent ee5dc97 commit df4c983
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/bee-q/src/components/input/bq-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,20 @@ export class BqInput {
// =======================================================

private handleBlur = () => {
if (this.disabled) return;

this.bqBlur.emit(this.el);
};

private handleFocus = () => {
if (this.disabled) return;

this.bqFocus.emit(this.el);
};

private handleInput = (ev: Event) => {
if (this.disabled) return;

this.debounceBqInput?.cancel();

if (!isHTMLElement(ev.target, 'input')) return;
Expand All @@ -248,13 +254,17 @@ export class BqInput {
};

private handleChange = (ev: Event) => {
if (this.disabled) return;

if (!isHTMLElement(ev.target, 'input')) return;
this.value = ev.target.value;

this.bqChange.emit({ value: this.value, el: this.el });
};

private handleClearClick = (ev: CustomEvent) => {
if (this.disabled) return;

this.inputElem.value = '';
this.value = this.inputElem.value;

Expand Down Expand Up @@ -347,7 +357,7 @@ export class BqInput {
onInput={this.handleInput}
/>
{/* Clear Button */}
{!this.disableClear && this.hasValue && (
{this.hasValue && !this.disabled && !this.disableClear && (
// The clear button will be visible as long as the input has a value
// and the parent group is hovered or has focus-within
<bq-button
Expand Down

0 comments on commit df4c983

Please sign in to comment.