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

fix issue with datatable tooltip #4933

Merged
merged 2 commits into from
Feb 21, 2025
Merged

Conversation

InesaFitsner
Copy link
Contributor

@InesaFitsner InesaFitsner commented Feb 21, 2025

Description

DataTable column tooltip was shown incorrectly because of Control tooltip. When clicking on Column, "/" symbols were added to tooltip value.

Test Code

# Test code for the review of this PR

import logging

import flet as ft

# logging.basicConfig(level=logging.DEBUG)


def main(page: ft.Page):
    def sort_column(e):
        print(f"{e.column_index}, {e.ascending}")
        print(e.control)
        dt.sort_column_index = e.column_index
        dt.sort_ascending = e.ascending
        dt.update()

    page.add(
        dt := ft.DataTable(
            width=700,
            bgcolor="yellow",
            border=ft.border.all(2, "red"),
            border_radius=10,
            vertical_lines=ft.BorderSide(3, "blue"),
            horizontal_lines=ft.BorderSide(1, "green"),
            sort_column_index=1,
            sort_ascending=False,
            heading_row_color=ft.Colors.BLACK12,
            heading_row_height=100,
            data_row_color={ft.ControlState.HOVERED: "0x30FF0000"},
            show_checkbox_column=True,
            divider_thickness=0,
            column_spacing=200,
            columns=[
                ft.DataColumn(
                    ft.Text("Column 1"),
                    on_sort=sort_column,
                ),
                ft.DataColumn(
                    ft.Text("Column 2"),
                    tooltip="This is a second column",
                    numeric=True,
                    on_sort=sort_column,
                ),
            ],
            rows=[
                ft.DataRow(
                    [ft.DataCell(ft.Text("A")), ft.DataCell(ft.Text("1"))],
                    selected=True,
                    on_select_changed=lambda e: print(f"row select changed: {e.data}"),
                ),
                ft.DataRow([ft.DataCell(ft.Text("B")), ft.DataCell(ft.Text("2"))]),
            ],
        ),
    )


ft.app(main)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist

  • I signed the CLA.
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • New and existing tests pass locally with my changes
  • I have made corresponding changes to the documentation (if applicable)

Screenshots

Additional details

Summary by Sourcery

Bug Fixes:

  • Fixed an issue where the DataTable column tooltip was incorrectly displayed due to interference from the Control tooltip, which also caused "/" symbols to be added to the tooltip value when clicking on a column.

Copy link
Contributor

@ndonkoHenri ndonkoHenri left a comment

Choose a reason for hiding this comment

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

Can you please test that it still works in other controls: #4049 #4378

@InesaFitsner
Copy link
Contributor Author

I changed Segment tooltip not to be passed to Control constructor. Tested both SegmentedButton and BarChart - works ok.

@ndonkoHenri
Copy link
Contributor

Tested both SegmentedButton and BarChart - works ok.

Great, thanks!

@FeodorFitsner FeodorFitsner merged commit 906f01c into main Feb 21, 2025
2 checks passed
@FeodorFitsner FeodorFitsner deleted the inesa-datatable-tooltip branch February 21, 2025 19:15
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.

3 participants