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: Tooltip displays wrong message when used with IconButton, FloatingActionButton and PopupMenuButton #3922

Merged
merged 2 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions packages/flet/lib/src/controls/create_control.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1089,11 +1089,7 @@ Widget _opacity(
Widget _tooltip(
Widget widget, ThemeData theme, Control? parent, Control control) {
var tooltip = parseTooltip(control, "tooltip", widget, theme);
return tooltip != null &&
!["iconbutton", "floatingactionbutton", "popupmenubutton"]
.contains(control.type)
? tooltip
: widget;
return tooltip != null ? tooltip : widget;
}

Widget _aspectRatio(Widget widget, Control? parent, Control control) {
Expand Down
5 changes: 0 additions & 5 deletions packages/flet/lib/src/controls/floating_action_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class FloatingActionButtonControl extends StatelessWidget {
parseClip(control.attrString("clipBehavior"), Clip.none)!;
var contentCtrls =
children.where((c) => c.name == "content" && c.isVisible);
var tooltip = control.attrString("tooltip");
bool autofocus = control.attrBool("autofocus", false)!;
bool mini = control.attrBool("mini", false)!;
bool? enableFeedback = control.attrBool("enableFeedback");
Expand Down Expand Up @@ -91,7 +90,6 @@ class FloatingActionButtonControl extends StatelessWidget {
enableFeedback: enableFeedback,
clipBehavior: clipBehavior,
focusColor: focusColor,
tooltip: tooltip,
shape: shape,
mini: mini,
child: createControl(control, contentCtrls.first.id, disabled,
Expand All @@ -114,7 +112,6 @@ class FloatingActionButtonControl extends StatelessWidget {
enableFeedback: enableFeedback,
clipBehavior: clipBehavior,
focusColor: focusColor,
tooltip: tooltip,
shape: shape,
mini: mini,
child: Icon(icon));
Expand All @@ -136,7 +133,6 @@ class FloatingActionButtonControl extends StatelessWidget {
enableFeedback: enableFeedback,
clipBehavior: clipBehavior,
focusColor: focusColor,
tooltip: tooltip,
shape: shape,
mini: mini,
child: Text(text),
Expand All @@ -161,7 +157,6 @@ class FloatingActionButtonControl extends StatelessWidget {
enableFeedback: enableFeedback,
clipBehavior: clipBehavior,
focusColor: focusColor,
tooltip: tooltip,
shape: shape,
);
} else {
Expand Down
3 changes: 0 additions & 3 deletions packages/flet/lib/src/controls/icon_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ class _IconButtonControlState extends State<IconButtonControl>
double? splashRadius = widget.control.attrDouble("splashRadius");
var padding = parseEdgeInsets(widget.control, "padding");
var alignment = parseAlignment(widget.control, "alignment");
var tooltip = widget.control.attrString("tooltip");
var contentCtrls =
widget.children.where((c) => c.name == "content" && c.isVisible);
bool autofocus = widget.control.attrBool("autofocus", false)!;
Expand Down Expand Up @@ -155,7 +154,6 @@ class _IconButtonControlState extends State<IconButtonControl>
iconSize: iconSize,
mouseCursor: mouseCursor,
visualDensity: visualDensity,
tooltip: tooltip,
style: style,
isSelected: selected,
selectedIcon: selectedIcon != null
Expand All @@ -180,7 +178,6 @@ class _IconButtonControlState extends State<IconButtonControl>
mouseCursor: mouseCursor,
visualDensity: visualDensity,
style: style,
tooltip: tooltip,
isSelected: selected,
selectedIcon: selectedIcon != null
? Icon(selectedIcon, color: selectedIconColor)
Expand Down
9 changes: 5 additions & 4 deletions packages/flet/lib/src/controls/popup_menu_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class PopupMenuButtonControl extends StatelessWidget with FletStoreMixin {
debugPrint("PopupMenuButton build: ${control.id}");

var icon = parseIcon(control.attrString("icon"));
var tooltip = control.attrString("tooltip", "")!;
var iconSize = control.attrDouble("iconSize");
var splashRadius = control.attrDouble("splashRadius");
var elevation = control.attrDouble("elevation");
Expand Down Expand Up @@ -62,8 +61,8 @@ class PopupMenuButtonControl extends StatelessWidget with FletStoreMixin {
.map((c) => c.id), (content, viewModel) {
return PopupMenuButton<String>(
enabled: !disabled,
tooltip: null,
icon: icon != null ? Icon(icon) : null,
tooltip: tooltip,
iconSize: iconSize,
splashRadius: splashRadius,
shadowColor: shadowColor,
Expand Down Expand Up @@ -144,10 +143,12 @@ class PopupMenuButtonControl extends StatelessWidget with FletStoreMixin {
}).toList(),
child: child);
});

debugPrint('SHOW: ${control.attrString("tooltip", "") != ""}');
ndonkoHenri marked this conversation as resolved.
Show resolved Hide resolved
return constrainedControl(
context,
TooltipVisibility(visible: tooltip != "", child: popupButton),
TooltipVisibility(
visible: control.attrString("tooltip") == null,
child: popupButton),
parent,
control);
}
Expand Down