Skip to content
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

[CP-2995] Introduce adjustedOffset logic to handle tooltip flipping adjustments #2110

Merged
merged 2 commits into from
Oct 7, 2024

Conversation

dkarski
Copy link
Member

@dkarski dkarski commented Oct 4, 2024

JIRA Reference: CP-2995

📝 Description ️

Refactor tooltip positioning logic by introducing adjustedOffset to handle flipping adjustments for more consistent and maintainable offset calculations.



// @ts-ignore
const view: View = {
  phoneDropdownCounterBadge: {
    component: "button-text",
    config: {
      actions: [],
      modifiers: ["hover-background"],
    },
    layout: {
      padding: "2px 5px",
    },
    dataProvider: {
      source: "entities-field",
      entitiesType: "contacts",
      fields: [
        {
          slice: [1],
          flat: "phoneNumber",
          providerField: "phoneNumbers",
          componentField: "extra-data.tooltip.contentList",
        },
      ],
    },
    extra: {
      tooltip: {
        placement: "bottom-left",
        offset: {
          x: 0,
          y: 15,
        },
      },
    },
    childrenKeys: ["phoneDropdownCounterBadgeText"],
  },
  columnCheckbox: {
    component: "table.cell",
    config: {
      width: "74",
    },
    layout: {
      padding: "0 0 0 32px",
    },
    childrenKeys: ["contactCheckbox"],
  },
  contactCheckbox: {
    component: "form.checkboxInput",
    config: {
      name: "selectedContacts",
      size: "small",
    },
    dataProvider: {
      source: "entities-field",
      entitiesType: "contacts",
      fields: [
        {
          providerField: "contactId",
          componentField: "config.value",
        },
      ],
    },
    extra: {
      tooltip: {
        contentText: "Select",
        offset: {
          x: 0,
          y: 15,
        },
      },
    },
  },
}

export default view
Zrzut ekranu 2024-10-4 o 10 58 48 Zrzut ekranu 2024-10-4 o 10 58 46 Zrzut ekranu 2024-10-4 o 10 21 45 Zrzut ekranu 2024-10-4 o 10 58 41

💪 Checklist before requesting a review - nice to have

  • getState function in async thunk actions is correctly typed
  • redux selectors are used in components / prop drilling is reduce

❗ Checklist before merging a pull request

  • change went through the QA process
  • translations are updated in dedicated application
  • CHANGELOG.md is updated

Copy link
Collaborator

@mkurczewski mkurczewski left a comment

Choose a reason for hiding this comment

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

Consider extracting calculatePosition and isWithinViewport functions out of handleAnchorHover scope.

@dkarski dkarski merged commit 51a226f into CP-2995 Oct 7, 2024
7 checks passed
@dkarski dkarski deleted the CP-2995-tooltip-offset-improvment branch October 7, 2024 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants