npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

materialize-css-helper

v1.0.9

Published

Materialize Helper

Downloads

126

Readme

Materialize Helper

Introduction

This package was introduced to collect and fix all common known issues of Materialize library without removing any features, but rather making them work as expected.

Known Issues

Currently there are few commonly known issues caused by the Materialize:

1. Select element is misbehaving on iOS

On iOS, when clicking one select dropdown option, other one is being selected. This issue is caused by the dropdown animation. This package will fix the bug while keeping the dropdown animation.

2. Lighthouse warning for Select element

Select trigger input causes a Lighthouse warning for not having a label or placeholder:

Form elements do not have associated labels

This package will dynamically add a placeholder depending on a selected option value.

3. Input label is not marked as active on autocompletion

When an input is autocompleted by the browser (i.e "username" and "password" fields), the onchange event for the input is not being triggered and that causes the label element to cover the input even tho it is autocompleted and filled in by the browser. This package will listen to onautocomplete event and assign .active class to the label forcing it to move up.

4. Materialize is adding non-passive event listeners

This is not fixed by this package. Use passive-events-support package to resolve it.

Installation

yarn add materialize-css-helper

Usage

By default, this package will automatically resolve all the in the Known Issues section mentioned issues. It's script will automatically be executed upon DOMContentLoaded.

Make sure this package is loaded after the Materialize script.

// With JS
import 'materialize-css-helper'
// to pass the custom configuration
import { initMaterializeHelper } from 'materialize-css-helper/src/utils'
initMaterializeHelper({/*...*/})
<!-- With HTML -->
<script>
  // if undefined will apply the default configuration
  window.materializeHelper = {/*...*/}
</script>
<script type="text/javascript" src="node_modules/materialize-css-helper/dist/main.js"></script>

Configuration

Every issue fix is optional and has it's toggle option.

Configurable Options

| Option | Type | Default | | --- | --- | --- | | debug | boolean | false | | selectOptions | boolean | true | | selectTriggers | boolean | true | | autocompletedInputLabels | boolean | true |

Option: debug

When enabled, fixed elements will be logged into console.

{
  debug: true
}

Console output

[Materialize Helper] Fixed select options
{ options: [
  0: Element
  1: Element
  2: Element
]}
// other logs...

Option: selectOptions

Whether M.Select element behaviour for iOS should be fixed. See the exact issue to learn more.

{
  selectOptions: true // default value
}

In case you prefer a css solution, you can disable the JavaScript fix by passing false and manually removing the select dropdown animation:

.dropdown-content {
  transform: none !important;
}

Option: selectTriggers

Whether select trigger input should have a placeholder assigned. See the exact issue to learn more.

{
  selectTriggers: true // default value
}

Option: autocompletedInputLabels

Whether label and input should be marked as filled in when autocompleted. See the exact issue to learn more.

{
  autocompletedInputLabels: true // default value
}

Reporting Issues

Please raise other Materialize caused issues and workarounds, so it could be added to this package.