Skip to content

Commit

Permalink
fix(datepicker): docs & console
Browse files Browse the repository at this point in the history
  • Loading branch information
aesteves60 authored and dpellier committed Nov 28, 2024
1 parent 7bbfdd1 commit d068035
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,9 @@ export class OdsDatepicker {
// Triggered either by user selection or `setDate` instance method call
this.inputElement.addEventListener('changeDate', (event: Event) => {
const newDate: Date = (event as CustomEvent).detail.date;
// console.log('changeDate', (event as CustomEvent).detail, newDate, this.value);
const formattedNewDate = formatDate(newDate, this.format);

const previousValue = this.value;
// console.log('changeDate newDate', newDate instanceof Date ? newDate.toISOString() : newDate);
// console.log('changeDate previousValue', previousValue instanceof Date ? previousValue.toISOString() : previousValue);
this.value = newDate ?? null;
this.onValueChange(formattedNewDate, previousValue);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ import type { SpecPage } from '@stencil/core/testing';
import { newSpecPage } from '@stencil/core/testing';
import { OdsDatepicker } from '../../src';

// @ts-ignore for test purposes
global.MutationObserver = jest.fn(() => ({
disconnect: jest.fn(),
observe: jest.fn(),
}));

describe('ods-datepicker rendering', () => {
let page: SpecPage;
let root: HTMLElement | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ export const Demo: StoryObj = {
const validityStateTemplate = html`<br>
<div id="validity-state-datepicker" style="display: grid; row-gap: 5px;"></div>
<script>
(() => {
(async() => {
const divValidityState = document.querySelector('#validity-state-datepicker');
const datepicker = document.querySelector('.my-datepicker');
console.log('datepicker', datepicker)
setTimeout(async() => await renderValidityState(), 0);
await customElements.whenDefined('ods-datepicker');
await renderValidityState();
datepicker.addEventListener('odsChange', () => {
setTimeout(async() => await renderValidityState(), 0);
await renderValidityState();
})
async function renderValidityState() {
const validity = await datepicker?.getValidity()
const validity = await datepicker.getValidity()
divValidityState.innerHTML = '';
for (let key in validity) {
divValidityState.innerHTML += "<div>" + key + ": " + validity[key] + "</div>";
Expand Down Expand Up @@ -175,6 +175,7 @@ export const Demo: StoryObj = {
type: { summary: 'boolean' },
},
control: 'boolean',
description: 'Toggle this to see the component validityState',
},
}),
args: {
Expand Down Expand Up @@ -325,9 +326,9 @@ export const ValidityState: StoryObj = {
(async() => {
const divValidityState = document.querySelector('#validity-state-demo');
const datepicker = document.querySelector('#datepicker-validity-state-demo');
setTimeout(async() => { await renderValidityState() }, 0)
datepicker.addEventListener('odsChange', () => {
setTimeout(async() => { await renderValidityState() }, 0)
await renderValidityState();
datepicker.addEventListener('odsChange', async() => {
await renderValidityState();
})
async function renderValidityState() {
const validity = await datepicker.getValidity();
Expand Down

0 comments on commit d068035

Please sign in to comment.