]> wagnertech.de Git - mfinanz.git/blobdiff - SL/Presenter/MaterialComponents.pm
kivitendo 3.9.2-0.2
[mfinanz.git] / SL / Presenter / MaterialComponents.pm
index 30123b7194cf63cbfce0302f1cadc6f481b9fdbc..d0ddfc483d2d9d28da85e91a17eb7327fd5688ce 100644 (file)
@@ -13,6 +13,7 @@ use Exporter qw(import);
 our @EXPORT_OK = qw(
   button_tag
   input_tag
+  textarea_tag
   date_tag
   submit_tag
   icon
@@ -231,6 +232,28 @@ sub input_tag {
   );
 }
 
+sub textarea_tag {
+  my ($name, $value, %attributes) = @_;
+
+  _set_id_attribute(\%attributes, $attributes{name});
+
+  my $class = delete $attributes{class};
+  my $icon  = $attributes{icon}
+    ? icon(delete $attributes{icon}, class => 'prefix')
+    : '';
+
+  my $label = $attributes{label}
+    ? html_tag('label', delete $attributes{label}, for => $attributes{id})
+    : '';
+
+  html_tag('div',
+    $icon .
+    html_tag('textarea', $value, class => 'materialize-textarea', %attributes, name => $name) .
+    $label,
+    class => [ grep $_, $class, INPUT_FIELD ],
+  );
+}
+
 sub date_tag {
   my ($name, $value, %attributes) = @_;
 
@@ -280,10 +303,11 @@ sub select_tag {
     : '';
 
   my $label = $attributes{label}
-    ? html_tag('label', delete $attributes{label}, for => $attributes{id})
+    ? html_tag('label', delete $attributes{label}, for => $attributes{id}, class => 'active')
     : '';
 
-  my $select_html = SL::Presenter::Tag::select_tag($name, $collection, %attributes);
+  my $select_html = SL::Presenter::Tag::select_tag($name, $collection, %attributes,
+    class => 'browser-default');
 
   html_tag('div',
     $icon . $select_html . $label,
@@ -343,9 +367,20 @@ directly as classes.
 
 =back
 
-=head1 BUGS
+=head1 BUGS & ISSUES
+
+There is a bug in MaterializeCSS, when using a Materialize select element on an iphone,
+the wrong element is selected. This is currently worked around in the presenter by using
+the 'browser-default' class on the select element as well as the 'active' class on the
+label (to prevent the label from overlapping the select element).
+This should be fixed, upstream, in MaterializeCSS. However it seems that the project is
+not maintained anymore (according to github issues[^1]). There is a community fork[^2],
+which it's still maintained and where the problem seems to be fixed already. It is currently
+in alpha V. 2.0.3-alpha. Maybe it would be good to consider switching to that fork at some
+point.
 
-Nothing here yet.
+[1]: e.g. https://github.com/Dogfalo/materialize/issues/6688
+[2]: https://github.com/materializecss/materialize
 
 =head1 AUTHOR