-
Notifications
You must be signed in to change notification settings - Fork 80
feat(list, list-item): add non-interactive option to remove hover/pointer changes. #10473
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
feat(list, list-item): add non-interactive option to remove hover/pointer changes. #10473
Conversation
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 we move the warning log to the list?
@Watch("interactionMode") | ||
@Watch("selectionAppearance") | ||
@Watch("selectionMode") | ||
handleInteractionModeSelectionAppearanceSelectionModeChange(): void { |
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 think this would need to be called on componentWillLoad
as well, otherwise it would only warn after one of these was changed.
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.
Should this warning occur on the list instead of the list item? The property on the list-item is internal so its weird to log here.
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 moved this logic into list.tsx 🚀
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.
Code looks good! can we just not reflect the internal prop?
* Specifies the interaction mode of the component - `"interactive"` (allows interaction styling and pointer changes on hover), `"static"` (does not allow interaction styling and pointer changes on hover), Do not combine `interaction-mode=“static”` and `selection-appearance=“border”`. | ||
* @internal | ||
*/ | ||
@Prop({ reflect: true }) interactionMode: InteractionMode = null; |
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.
Does this need to be reflected? Since its internal and not being used for a selector can we not reflect it?
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.
Thanks for catching this! I updated it to not be reflected.
this.selectionMode !== "none" && | ||
this.selectionAppearance === "border" | ||
) { | ||
console.warn(`selection-appearance=“border” requires interaction-mode=“interactive”`); |
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.
Do we need the warning or will good documentation suffice? Just questioning if this is indeed necessary.
This only warns on first use so if someone set these invalid combination after the fact there would be no warning. IMO we can just rely on doc for this but would love others thoughts.
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.
Aaron, Franco and me went over the issue, and landed on setting a detailed JSDoc for documentation while also logging the warning message. But maybe this can be reconsidered?
cc @jcfranco @ashetland
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.
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.
Great question. Since this is something teams have been asking for, let’s keep the warning in place to ensure developers use the proper configuration. After #10310, we can explore showing this and related warnings (e.g., color-picker’s incompatible value + format mode) only in dev builds, as suggested in #10038.
@ashetland @SkyeSeitz Can you please take a look at the new snapshots? |
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 to merge after addressing feedback.
👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍
👍✅👍👍👍✅👍👍✅✅👍👍✅✅✅👍👍✅✅✅👍✅✅✅✅👍✅👍
👍✅✅👍👍✅👍✅👍👍✅👍👍✅👍👍✅👍👍👍👍✅👍👍👍👍✅👍
👍✅👍✅👍✅👍✅👍👍✅👍👍✅👍👍✅👍👍👍👍✅✅✅👍👍✅👍
👍✅👍👍✅✅👍✅👍👍✅👍👍✅👍👍✅👍👍👍👍✅👍👍👍👍👍👍
👍✅👍👍👍✅👍👍✅✅👍👍✅✅✅👍👍✅✅✅👍✅✅✅✅👍✅👍
👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍
* | ||
* `"static"` does not allow interaction styling and pointer changes on hover | ||
* | ||
* Do not combine `interaction-mode=“static”` and `selection-appearance=“border”` |
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.
+@geospatialem @DitwanP for editorial review. 📖👀
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.
@aPreciado88 Can you speak more to the "why" behind not using the props together? Maybe something we can also add to enhance the component's documentation page. I didn't see context in the PR's summary or in the console warning, so wanted to be sure I understand the "why" a bit more before providing a review. Did observe different double quotes, so recommend changing those in the interim.
* Do not combine `interaction-mode=“static”` and `selection-appearance=“border”` | |
* Do not combine `interaction-mode="static"` and `selection-appearance="border"` |
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.
@geospatialem The reason for the console warning and not using the props together is described in this issue. Under Calcite Design Solution > selection-appearance=“border”.
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.
Summarizing our discussions via chat:
- We'll enhance the above to mention it is recommended to only add the
interaction-mode="static"
and"selection-appearance="none"
together (see suggestion below) - We'll provide more context via some images to the
list
's doc page under a new "Recommendations" section cc: @ashetland @jcfranco
* Do not combine `interaction-mode=“static”` and `selection-appearance=“border”` | |
* The `"static"` value should only be used when `selectionAppearance` is `"none"`. |
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.
The property should be selection-mode
, not selection-appearance
.
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.
Updated the PR with the requested changes. Thanks for catching that @ashetland!
@@ -1137,3 +1150,23 @@ export const dragEnabledNestedListsIndirectChildren = (): string => | |||
<div><calcite-list-item label="Depth 1" description="Item 6"></calcite-list-item></div> | |||
<div><calcite-list-item drag-disabled label="Depth 1" description="Item 7"></calcite-list-item></div> | |||
</calcite-list>`; | |||
|
|||
export const nonInteractive = (): string => html` |
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 you merge these stories into one with a descriptor for each use case (e.g., slider fill placements)?
@@ -1137,3 +1150,23 @@ export const dragEnabledNestedListsIndirectChildren = (): string => | |||
<div><calcite-list-item label="Depth 1" description="Item 6"></calcite-list-item></div> | |||
<div><calcite-list-item drag-disabled label="Depth 1" description="Item 7"></calcite-list-item></div> | |||
</calcite-list>`; | |||
|
|||
export const nonInteractive = (): string => html` | |||
<div style="width: 400px"> |
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.
Nitpick: is setting width
necessary for this test?
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 not necessary, I can take the width out.
@@ -682,7 +696,7 @@ export class ListItem | |||
aria-setsize={setSize} | |||
class={{ | |||
[CSS.container]: true, | |||
[CSS.containerHover]: true, | |||
[CSS.containerHover]: !containerNotInteractive || containerInteractive, |
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 naming a bit misleading. Since containerInteractive
and containerNotInteractive
are opposites, this ends up reading as containerInteractive || containerInteractive
.
@@ -668,6 +675,13 @@ export class ListItem | |||
const showBorder = selectionMode !== "none" && selectionAppearance === "border"; | |||
const borderSelected = showBorder && selected; | |||
const borderUnselected = showBorder && !selected; | |||
const containerNotInteractive = |
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 think this can be simplified to:
const containerInteractive =
interactionMode === "interactive" ||
(
interactionMode === "static" &&
selectionMode !== "none" &&
selectionAppearance === "border"
);
// ...
[CSS.containerHover]: containerInteractive,
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.
Thanks for catching that, this update works!
Lookin' good! |
…nter changes. (#10473) **Related Issue:** [#8634](#8634) ## Summary - Add `interaction-mode="interactive" (default) | "static"` prop. - Setting `interaction-mode="static"` and `selection-appearance="icon"` removes hover/pointer changes from main content area. - Setting `interaction-mode="static"` and `selection-appearance="border"` falls back to interactive hover/pointer changes and logs console warning message. - Setting `interaction-mode="static"` and `selection-mode="none"` removes hover/pointer changes.
Related Issue: #8634
Summary
interaction-mode="interactive" (default) | "static"
prop.interaction-mode="static"
andselection-appearance="icon"
removes hover/pointer changes from main content area.interaction-mode="static"
andselection-appearance="border"
falls back to interactive hover/pointer changes and logs console warning message.interaction-mode="static"
andselection-mode="none"
removes hover/pointer changes.