-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(panel): Fix heading border when only text content is slotted #7491
Conversation
.map((node) => node.textContent) | ||
.join("") | ||
.trim(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anveshmekala I think this utility could be used for...
calcite-design-system/packages/calcite-components/src/components/text-area/text-area.tsx
Lines 406 to 415 in bb07831
contentSlotChangeHandler = (): void => { | |
if (!this.value) { | |
const nodes = this.el.childNodes; | |
nodes.forEach((el) => { | |
if (el.nodeName === "#text") { | |
this.value = el.nodeValue.trim(); | |
} | |
}); | |
} | |
}; |
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little confused about the logic above though, it seems like the last textNode will be set as this.value
and any previous nodes would be overwritten.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good observation. I agree that it does seem suspect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anveshmekala I think this utility could be used for...
calcite-design-system/packages/calcite-components/src/components/text-area/text-area.tsx
Lines 406 to 415 in bb07831
contentSlotChangeHandler = (): void => { if (!this.value) { const nodes = this.el.childNodes; nodes.forEach((el) => { if (el.nodeName === "#text") { this.value = el.nodeValue.trim(); } }); } }; What do you think?
This works well for text-area use-case of extracting text. Regarding the logic , if we have multiple textNodes then yes the last node will be set as value
. I wonder if there could be a case where one can have multiple textNodes . Multi-line text will still be considered as one textNode i believe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anveshmekala I think this breaks the logic:
<calcite-text-area>
Hello
world
hi</calcite-text-area>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://codepen.io/driskull/pen/oNQREpy?editors=1111
It seems to work but could you double check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it works with multi line text including special characters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, but can we separate the utils that aren't related to the fix for now?
.map((node) => node.textContent) | ||
.join("") | ||
.trim(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good observation. I agree that it does seem suspect.
This is a great update but I think a lot of the doc site use cases would still have the missing border - can we only hide one of the duplicate borders when footer content is populated or footer / header containers are intersecting? |
Can you explain why? |
We'll have to brainstorm because it's not just the footer that is the problem. When a popup is collapsed, we don't want the border line showing here as it would divide nothing and put a line through the pointer tail. |
Maybe we need to build collapsing into the panel/flow-item to handle this correctly? Then it would only be removed when |
Another option would be the ability to turn off the border when necessary through a CSS variable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! 🚀
packages/calcite-components/src/components/panel/panel.stories.ts
Outdated
Show resolved
Hide resolved
@@ -12,6 +12,7 @@ | |||
|
|||
--calcite-min-header-height: calc(var(--calcite-icon-size) * 3); | |||
--calcite-panel-footer-padding: theme("spacing.2"); | |||
--calcite-internal-panel-header-border-block-end: 1px solid var(--calcite-ui-border-3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the -internal
be at the end? I think that's the pattern elsewhere - maybe we can add that to conventions?
--calcite-chip-spacing-s-internal: theme("spacing[1]"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
☝️ this is actually inconsistent with some other internal CSS props. 😅
I think internal
should be more prominent in the name. This might be easier to spot if it's part of the prefix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can add that to conventions?
Excellent idea. I don't think we have this documented at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I looked at other internal css props and some start with internal and some end with internal. Can we open an issue for a convention and refactoring?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOL - yeah it's about 50/50. I feel like it's easier to spot at the end with nothing following it but... as long as its consistent either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like we should follow events as they are prefixed with calciteInternal
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢 it
@macandcheese @jcfranco good to merge? |
Good to murge! 🚀 |
🤖 I have created a release *beep* *boop* --- <details><summary>@esri/calcite-components: 1.6.0</summary> ## [1.6.0](https://github.com/Esri/calcite-design-system/compare/@esri/[email protected]...@esri/[email protected]) (2023-08-15) ### Features * **action-bar:** Add "actions-end" slot (deprecates "bottom-actions") ([#7435](#7435)) ([1bf14ff](1bf14ff)) ### Bug Fixes * **block:** Defaults the status icon to `scale=s` ([#7503](#7503)) ([e1aee99](e1aee99)) * **button,card,fab,inline-editable:** Provides context to AT users when loading ([#7257](#7257)) ([df33eda](df33eda)) * **chip-group:** Add existence checks ([#7487](#7487)) ([33225a7](33225a7)) * **combobox:** Prevents navigation list with Space key ([#7505](#7505)) ([58e2ff2](58e2ff2)) * **panel:** Fix heading border when only text content is slotted ([#7491](#7491)) ([7704400](7704400)) * **progress:** Completes animation for `dir='rtl'` ([#7511](#7511)) ([c5d6ada](c5d6ada)) * **scrim:** Handle slotted children correctly ([#7477](#7477)) ([c5ce008](c5ce008)) * **scrim:** Render text content inside scrim ([#7509](#7509)) ([643ce5d](643ce5d)) * **slider:** Rerender ticks when prop is modified ([#7439](#7439)) ([20058a9](20058a9)) * **tree:** Selects all child items when selection-mode is set to ancestors ([#7518](#7518)) ([f1eef84](f1eef84)) </details> <details><summary>@esri/calcite-components-react: 1.6.0</summary> ## [1.6.0](https://github.com/Esri/calcite-design-system/compare/@esri/[email protected]...@esri/[email protected]) (2023-08-15) ### Bug Fixes * Prevent vitetest/ssr errors due to defining components on the server ([#7521](#7521)) ([046672e](046672e)) ### Dependencies * The following workspace dependencies were updated * dependencies * @esri/calcite-components bumped from ^1.6.0-next.7 to ^1.6.0 </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
🤖 I have created a release *beep* *boop* --- <details><summary>@esri/calcite-components: 1.6.0</summary> ## [1.6.0](https://github.com/Esri/calcite-design-system/compare/@esri/[email protected]...@esri/[email protected]) (2023-08-15) ### Features * **action-bar:** Add "actions-end" slot (deprecates "bottom-actions") ([#7435](#7435)) ([1bf14ff](1bf14ff)) ### Bug Fixes * **block:** Defaults the status icon to `scale=s` ([#7503](#7503)) ([e1aee99](e1aee99)) * **button,card,fab,inline-editable:** Provides context to AT users when loading ([#7257](#7257)) ([df33eda](df33eda)) * **chip-group:** Add existence checks ([#7487](#7487)) ([33225a7](33225a7)) * **combobox:** Prevents navigation list with Space key ([#7505](#7505)) ([58e2ff2](58e2ff2)) * **panel:** Fix heading border when only text content is slotted ([#7491](#7491)) ([7704400](7704400)) * **progress:** Completes animation for `dir='rtl'` ([#7511](#7511)) ([c5d6ada](c5d6ada)) * **scrim:** Handle slotted children correctly ([#7477](#7477)) ([c5ce008](c5ce008)) * **scrim:** Render text content inside scrim ([#7509](#7509)) ([643ce5d](643ce5d)) * **slider:** Rerender ticks when prop is modified ([#7439](#7439)) ([20058a9](20058a9)) * **tree:** Selects all child items when selection-mode is set to ancestors ([#7518](#7518)) ([f1eef84](f1eef84)) </details> <details><summary>@esri/calcite-components-react: 1.6.0</summary> ## [1.6.0](https://github.com/Esri/calcite-design-system/compare/@esri/[email protected]...@esri/[email protected]) (2023-08-15) ### Bug Fixes * Prevent vitetest/ssr errors due to defining components on the server ([#7521](#7521)) ([046672e](046672e)) ### Dependencies * The following workspace dependencies were updated * dependencies * @esri/calcite-components bumped from ^1.6.0-next.7 to ^1.6.0 </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Related Issue: #7489
Summary