Skip to content

Commit

Permalink
fix(Timepicker) compatibility with no modal materializecss#525 materi…
Browse files Browse the repository at this point in the history
  • Loading branch information
gselderslaghs committed Dec 29, 2024
1 parent 65ddf18 commit 268ae1e
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/timepicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,13 @@ export class Timepicker extends Component<TimepickerOptions> {
}

_handleInputClick = () => {
this.open();
this.inputHours.focus();
};

_handleInputKeydown = (e: KeyboardEvent) => {
if (Utils.keys.ENTER.includes(e.key)) {
e.preventDefault();
this.open();
this.inputHours.focus();
}
};

Expand Down Expand Up @@ -296,9 +296,10 @@ export class Timepicker extends Component<TimepickerOptions> {
}

if (this.currentView === 'hours') {
this.inputMinutes.focus();
this.showView('minutes', this.options.duration / 2);
} else {
this.minutesView.classList.add('timepicker-dial-out');
// this.minutesView.classList.add('timepicker-dial-out');
setTimeout(() => {
this.done();
}, this.options.duration / 2);
Expand Down Expand Up @@ -381,6 +382,8 @@ export class Timepicker extends Component<TimepickerOptions> {
doneButton.classList.add('timepicker-close');
//doneButton.addEventListener('click', this._finishSelection);
confirmationBtnsContainer.appendChild(doneButton);
this._updateTimeFromInput();
this.showView('hours');
}

_clockSetup() {
Expand Down Expand Up @@ -726,8 +729,7 @@ export class Timepicker extends Component<TimepickerOptions> {
this.inputHours.value = (this.hours % (this.options.twelveHour ? 12 : 24)).toString();
}

// todo: remove e
done = (e = null, clearValue = null) => {
done = (clearValue = null) => {
// Set input value
const last = this.el.value;
let value = clearValue
Expand All @@ -744,18 +746,14 @@ export class Timepicker extends Component<TimepickerOptions> {
new Event('change', { bubbles: true, cancelable: true, composed: true })
);
}
//this.el.focus();
return e; // just for passing linter, can be removed
};

clear = () => {
this.done(null, true);
this.done(true);
};

// deprecated
open() {
// this._updateTimeFromInput();
// this.showView('hours');
console.warn(
'Timepicker.close() is deprecated. Remove this method and wrap in modal yourself.'
);
Expand All @@ -777,7 +775,7 @@ export class Timepicker extends Component<TimepickerOptions> {
<div class="timepicker-text-container">
<div class="timepicker-display-column">
<div class="timepicker-input-hours-wrapper">
<input type="text" maxlength="2" autofocus class="timepicker-input-hours text-primary" />
<input type="text" maxlength="2" class="timepicker-input-hours text-primary" />
</div>
<div class="timepicker-input-divider-wrapper">
<span class="timepicker-input-divider">:</span>
Expand Down

0 comments on commit 268ae1e

Please sign in to comment.