fix(calendar): reflect the orientation attr.#1775
Merged
Conversation
41532cf to
8f1abe7
Compare
fa359ca to
6c7ae4e
Compare
This comment was marked as resolved.
This comment was marked as resolved.
…ce of vertical content part
rkaraivanov
reviewed
Jul 9, 2025
Member
rkaraivanov
left a comment
There was a problem hiding this comment.
LGTM with some suggestions
src/components/calendar/calendar.ts
Outdated
| flexGrow: 1, | ||
| flexDirection: direction ? 'row' : 'column', | ||
| }; | ||
| const part = direction ? 'content' : 'content content-vertical'; |
Member
There was a problem hiding this comment.
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.
src/components/calendar/calendar.ts
Outdated
| return html` | ||
| ${this.renderHeader()} | ||
| <div ${ref(this.contentRef)} part="content" style=${styleMap(styles)}> | ||
| <div ${ref(this.contentRef)} part="${part}"> |
Member
There was a problem hiding this comment.
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'); | ||
|
|
Member
There was a problem hiding this comment.
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'); |
Member
There was a problem hiding this comment.
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; |
rkaraivanov
previously approved these changes
Jul 10, 2025
simeonoff
reviewed
Jul 10, 2025
|
|
||
| [part='content-vertical'] { | ||
| flex-direction: column; | ||
|
|
| border-top-right-radius: 0; | ||
| } | ||
|
|
||
| [part='content-vertical'] { |
Collaborator
There was a problem hiding this comment.
Suggested change
| [part='content-vertical'] { | |
| [part~='content-vertical'] { |
| @@ -140,11 +140,18 @@ | |||
| } | |||
|
|
|||
| [part='content'] { | |||
Collaborator
There was a problem hiding this comment.
Suggested change
| [part='content'] { | |
| [part~='content'] { |
simeonoff
approved these changes
Jul 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes: #1711