Skip to content
This repository was archived by the owner on Apr 24, 2024. It is now read-only.
This repository was archived by the owner on Apr 24, 2024. It is now read-only.

mapbox-address-autofill component too aggressive with css injection in shadow root #1375

@togakangaroo

Description

@togakangaroo

I am using the AddressAutofill component from @mapbox/search-js-react and am using material ui for my input. When using them in conjunction

    <AddressAutofill
      accessToken={mapboxUiApiKey}
      onRetrieve={(x: AddressAutofillRetrieveResponse) =>
        setSelectedMapboxObject(x.features[0] ?? null)
      }
    >
      <TextField
        label="Address Search"
        variant="outlined"
        fullWidth
        margin="normal"
        value={addressInput}
        onChange={(e) => setAddressInput(e.target.value)}
      />
    </AddressAutofill>

I get a nasty alignment error

label is not aligned properly

After several hours investigating why this is happening, I can see that mapbox generates a mapbox-address-autofill shadow root which imparts a css style of

* { box-sizing: border-box !important; }

on everything - including my MUI input!.

This is going to break MUI's internal calculation of input height and is just all-around bad practice and not being good to your users.

Worse, the solution to this is not straightforward since !important flags cannot be passed to style blocks in MUI. That's why you don't use !important on stuff with wide css specifiers!!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy