Skip to content

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

Conversation

aPreciado88
Copy link
Contributor

@aPreciado88 aPreciado88 commented Oct 1, 2024

Related Issue: #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.

@github-actions github-actions bot added the enhancement Issues tied to a new feature or request. label Oct 1, 2024
@aPreciado88 aPreciado88 added this to the 2024-10-29 - Oct Milestone milestone Oct 1, 2024
@aPreciado88 aPreciado88 added the pr ready for visual snapshots Adding this label will run visual snapshot testing. label Oct 3, 2024
Copy link
Member

@driskull driskull left a 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 {
Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor Author

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 🚀

@aPreciado88 aPreciado88 requested a review from driskull October 11, 2024 18:36
Copy link
Member

@driskull driskull left a 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;
Copy link
Member

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?

Copy link
Contributor Author

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”`);
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I defer to @jcfranco and @driskull.

Copy link
Member

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.

@aPreciado88 aPreciado88 added pr ready for visual snapshots Adding this label will run visual snapshot testing. and removed pr ready for visual snapshots Adding this label will run visual snapshot testing. labels Oct 11, 2024
@aPreciado88
Copy link
Contributor Author

@ashetland @SkyeSeitz Can you please take a look at the new snapshots?

Copy link
Member

@jcfranco jcfranco left a 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”`
Copy link
Member

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. 📖👀

Copy link
Member

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.

Suggested change
* Do not combine `interaction-mode=static` and `selection-appearance=border`
* Do not combine `interaction-mode="static"` and `selection-appearance="border"`

Copy link
Contributor Author

@aPreciado88 aPreciado88 Oct 21, 2024

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”.

Copy link
Member

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
Suggested change
* Do not combine `interaction-mode=“static”` and `selection-appearance=“border”`
* The `"static"` value should only be used when `selectionAppearance` is `"none"`.

Copy link
Contributor

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.

Copy link
Contributor Author

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`
Copy link
Member

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">
Copy link
Member

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?

Copy link
Contributor Author

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,
Copy link
Member

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 =
Copy link
Member

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,

Copy link
Contributor Author

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!

@aPreciado88 aPreciado88 added pr ready for visual snapshots Adding this label will run visual snapshot testing. and removed pr ready for visual snapshots Adding this label will run visual snapshot testing. labels Oct 18, 2024
@ashetland
Copy link
Contributor

Lookin' good!

@ashetland ashetland self-requested a review October 18, 2024 20:15
@aPreciado88 aPreciado88 added pr ready for visual snapshots Adding this label will run visual snapshot testing. and removed pr ready for visual snapshots Adding this label will run visual snapshot testing. labels Oct 21, 2024
@aPreciado88 aPreciado88 added the skip visual snapshots Pull requests that do not need visual regression testing. label Oct 21, 2024
@aPreciado88 aPreciado88 merged commit c149b55 into dev Oct 21, 2024
17 checks passed
@aPreciado88 aPreciado88 deleted the aPreciado88/8634-add-non-interactive-option-to-remove-pointer-and-hover-changes branch October 21, 2024 20:51
benelan pushed a commit that referenced this pull request Feb 8, 2025
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Issues tied to a new feature or request. skip visual snapshots Pull requests that do not need visual regression testing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants