microsoftgraph / microsoft-graph-toolkit

Authentication Providers and UI components for Microsoft Graph 🦒
https://docs.microsoft.com/graph/toolkit/overview
Other
943 stars 300 forks source link

Changing the LocalizationHelper.strings does not show the custom strings #3151

Closed Ofer-Gal closed 2 months ago

Ofer-Gal commented 6 months ago

I added

LocalizationHelper.strings = {
  noResultsFound: "Not Found",
  _components: {
    "people-picker": {
      inputPlaceholderText: 'Search for Author',
      maxSelectionsPlaceHolder:'ok' 
    }
  }
};

Still shows the default values.

String name Default value inputPlaceholderText Search for a name maxSelectionsPlaceHolder Max contacts added

I use react in a SPFx webpart and MGT 4.2.1

            <PeoplePicker      type={'person'}  selectionMode={'single'} showMax={1}/>

Please help

cdragosf commented 6 months ago

Hi, where did you put those lines of code, in wich file?

Try to put the code provided by you on the main .ts webpart file not .tsx I have placed mine just after the last import {...} from "...."; line and out of the default webpart class.

Give it a try.

Ofer-Gal commented 6 months ago

Thanks for the answer. I moved it to the ...WebPart.ts after the last import {...} from "...."; line I did not understand "and out of the default webpart class." did you mean the main TSX file? then I did. (not using classes) Anyway it did not make a difference. Still shows the defaults. Also, I question the usability of having just one central setting. For the "inputPlaceholderText" property I can use the controls "placeholder" property so each PeoplePicker will have its own message. But for the "maxSelectionsPlaceHolder" There is no control property to specify but a developer may want a specific message for each PeoplePicker. Say "No more users" Vs "no more Guests"

Maybe I missed something?

I use 4.2.1 version now and it works 😂

musale commented 4 months ago

I use 4.2.1 version now and it works 😂

@Ofer-Gal does this mean using the v4.2.1 fixed this?

Ofer-Gal commented 4 months ago

Yes even if you have a different LocalizationHelper.strings for each component (*.tsx)

Ofer-Gal commented 2 months ago

Now with version 4.3.2 it works in one project but not other. Why Can't it be just a property of "PeoplePicker"

Ofer-Gal commented 2 months ago

In new project maxSelectionsPlaceHolder: '', works fine but the empty space should go away. image How can I remove the input altogether?

musale commented 2 months ago

In new project maxSelectionsPlaceHolder: '', works fine but the empty space should go away. image How can I remove the input altogether?

You can't remove. We can make that a separate issue so that if you've that property, we can reduce the length or wrap the input not to show.

Ofer-Gal commented 2 months ago

How do I do that?

musale commented 2 months ago

How do I do that?

Done here https://github.com/microsoftgraph/microsoft-graph-toolkit/issues/3255 add any more context by editing it