Skip to content

Commit

Permalink
feat: add watch on placeholder prop and previos console errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ayeshaa-m committed Apr 14, 2023
1 parent b0ae6f6 commit 962a09f
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions packages/components/src/components/date-picker/date-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,17 @@ export class DatePicker {
this.duetInput.querySelector('.duet-date__input').value = this.value;
}

/**
* Watch `placeholder` property for changes and update `placeholder` based on that.
*/
@Watch('placeholder')
onPlaceholderChange(newValue: string) {
const input = this.duetInput.querySelector('.duet-date__input');
if (input && this.placeholder) {
input.setAttribute('placeholder', newValue);
}
}

componentWillLoad() {
if (this.popupTitle !== 'Pick a date') {
statusNote({
Expand Down Expand Up @@ -380,6 +391,11 @@ export class DatePicker {
*/
adjustButtonsLabelsForA11y = () => {
const table = this.hostElement.querySelector('.duet-date__table');
if (!table) {
// The node we need does not exist yet. Wait and try again.
setTimeout(this.adjustButtonsLabelsForA11y);
return;
}
const options = { subtree: true, childList: true, attributes: true };
const callback = () => {
this.mo.disconnect(); // avoid a feedback loop
Expand All @@ -399,10 +415,12 @@ export class DatePicker {
};

disconnectedCallback() {
const input = this.duetInput.querySelector('.duet-date__input');
if (this.duetInput) {
const input = this.duetInput.querySelector('.duet-date__input');

if (input) {
input.removeEventListener('keyup', this.handleKeyPress);
if (input) {
input.removeEventListener('keyup', this.handleKeyPress);
}
}

if (this.mo) {
Expand Down

0 comments on commit 962a09f

Please sign in to comment.