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

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!!!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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