Skip to content

fix(calendar): reflect the orientation attr.#1775

Merged
simeonoff merged 14 commits intomasterfrom
mpopov/calendar-orientation-attr
Jul 10, 2025
Merged

fix(calendar): reflect the orientation attr.#1775
simeonoff merged 14 commits intomasterfrom
mpopov/calendar-orientation-attr

Conversation

@desig9stein
Copy link
Copy Markdown
Contributor

Closes: #1711

@desig9stein desig9stein requested a review from simeonoff July 7, 2025 06:56
@desig9stein desig9stein force-pushed the mpopov/calendar-orientation-attr branch from 41532cf to 8f1abe7 Compare July 7, 2025 13:18
@desig9stein desig9stein marked this pull request as draft July 7, 2025 13:28
@desig9stein desig9stein marked this pull request as ready for review July 7, 2025 13:48
@desig9stein desig9stein force-pushed the mpopov/calendar-orientation-attr branch from fa359ca to 6c7ae4e Compare July 7, 2025 13:51
@yradoeva

This comment was marked as resolved.

Copy link
Copy Markdown
Member

@rkaraivanov rkaraivanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with some suggestions

flexGrow: 1,
flexDirection: direction ? 'row' : 'column',
};
const part = direction ? 'content' : 'content content-vertical';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const part = direction ? 'content' : 'content content-vertical';
const parts = {
content: true,
'content-vertical': this._isDayView && this.orientation === 'vertical',
};

You can also delete the direction variable above it.

return html`
${this.renderHeader()}
<div ${ref(this.contentRef)} part="content" style=${styleMap(styles)}>
<div ${ref(this.contentRef)} part="${part}">
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<div ${ref(this.contentRef)} part="${part}">
<div ${ref(this.contentRef)} part=${partMap(parts)}>

Comment on lines -143 to -149
it('should change orientation', async () => {
const dom = getCalendarDOM(calendar);

expect(
getComputedStyle(dom.content).getPropertyValue('flex-direction')
).to.equal('row');

Copy link
Copy Markdown
Member

@rkaraivanov rkaraivanov Jul 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean you can adjust the getCalendarDOM helper function to query the content part with the right selector instead of outright removing the check.

This is the current version of the calendar DOM content getter.

get content() {
  return root.querySelector<HTMLElement>('[part="content"]')!;
}

Comment on lines +147 to +152
const contentEl = calendar.shadowRoot?.querySelector('[part~="content"]');
expect(contentEl).to.exist;

const partAttr = contentEl?.getAttribute('part') || '';
const parts = partAttr.split(/\s+/);
expect(parts).to.include('content-vertical');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you update the getCalendarDOM function to correctly return the content container you can simplify this to:

Suggested change
const contentEl = calendar.shadowRoot?.querySelector('[part~="content"]');
expect(contentEl).to.exist;
const partAttr = contentEl?.getAttribute('part') || '';
const parts = partAttr.split(/\s+/);
expect(parts).to.include('content-vertical');
expect(dom.content).to.exist;
expect(dom.content.part.contains('content-vertical')).to.be.true;

@desig9stein desig9stein requested a review from rkaraivanov July 9, 2025 13:20
rkaraivanov
rkaraivanov previously approved these changes Jul 10, 2025

[part='content-vertical'] {
flex-direction: column;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

border-top-right-radius: 0;
}

[part='content-vertical'] {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[part='content-vertical'] {
[part~='content-vertical'] {

@@ -140,11 +140,18 @@
}

[part='content'] {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[part='content'] {
[part~='content'] {

@simeonoff simeonoff merged commit 29c311a into master Jul 10, 2025
5 checks passed
@simeonoff simeonoff deleted the mpopov/calendar-orientation-attr branch July 10, 2025 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Date Picker] Dropdown/Dialog, Vertical orientation, 2 or more months - the left and right paddings of the months are not correct

4 participants