Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModernTaxonomyPicker - allowMultipleSelections = false, but panel allows multiple items to be selected #1847

Open
roldengarm opened this issue Jul 5, 2024 · 12 comments
Assignees
Labels
status:fixed-next-drop Issue will be fixed in upcoming release. type:bug
Milestone

Comments

@roldengarm
Copy link

Category

[ ] Enhancement

[X] Bug

[ ] Question

Version

Please specify what version of the library you are using: 3.18.1

If you are not using the latest release, please update and see if the issue is resolved before submitting an issue.

Expected / Desired Behavior / Question

When allowMultipleSelections is false, I shouldn't be able to select more than one item in the tree view.

Observed Behavior

Multiple items can be selected in the tree view in the panel. It still only allows selecting one item in the picker itself, but the treeview should not allow multiple selections.

Steps to Reproduce

<ModernTaxonomyPicker
                allowMultipleSelections={false}
                termSetId={this.state.businessGroupTermSetId}
                panelTitle="Select Business Group"
                label="Business Group or Unit"
                context={this.props.context}
              />

Then, just click the Label button to open the panel and try to select more than one.

image

A change in onPickerChange is most likely required to only select one item when allowMultipleSelections is false: https://github.com/pnp/sp-dev-fx-controls-react/blob/master/src/controls/modernTaxonomyPicker/taxonomyPanelContents/TaxonomyPanelContents.tsx#L66

Copy link

github-actions bot commented Jul 5, 2024

Thank you for submitting your first issue to this project.

@NishkalankBezawada
Copy link
Contributor

NishkalankBezawada commented Aug 22, 2024

Hello @roldengarm,

Did you try checking with the latest version v3.19?

Also, as per the documentation, you can try like this incase if you dont want multi-selection

image

I have tried like below, and it works fine

        <div id="taxPickerDiv">
          <ModernTaxonomyPicker
            termSetId={"9b18fd02-e738-41c7-b648-ea26a891267f"}
            panelTitle="Taxonomy Picker"
            label={"Taxonomy Picker"}
            context={this.props.context}
            required={false}
            disabled={false}
            customPanelWidth={400}
          />
        </div>

I have removed allowMultipleSelections, as this property is not required, and the default value is false.

If I have your approach, I am able to select multiple values in the panel, which is not correct. I will come up with a solution for this. Mean while you can remove the property allowMultipleSelections={false} to make it work.

Thanks,
Nishkalank Bezawada

@ludes2
Copy link

ludes2 commented Sep 11, 2024

@roldengarm I have exactly the same problem.
i am using v3.17 and have tried v3.19 and the bug persists.
Also, i tried to not set explicitly the prop allowMultipleSelections, but this has no effect.
there seems to be a problem with the is-checked class which does not get removed by clicking on an other option
isChecked
Did you found a solution in the meantime?

@roldengarm
Copy link
Author

@ludes2 no solution unfortunately.

@lucadercoli
Copy link

I'm facing the same issue and tried the solution proposed by @NishkalankBezawada,
but as mentioned by @Ludes, the bug still persists.
I also tried using the beta version, but it doesn't work either.

Has anyone else found an alternative solution that works?

@NishkalankBezawada
Copy link
Contributor

I'm facing the same issue and tried the solution proposed by @NishkalankBezawada,

but as mentioned by @Ludes, the bug still persists.

I also tried using the beta version, but it doesn't work either.

Has anyone else found an alternative solution that works?

Hey @lucadercoli, couldn't get you clearly, did my solution work?

//Nishkalank

@lucadercoli
Copy link

Hi @NishkalankBezawada, thank you for your suggestion. Unfortunately, after trying your proposed solution, the bug is still present. I also tried the beta version, but it didn't resolve the issue either. Could you suggest any other possible fixes? Has anyone else found an alternative solution that worked?

@ludes2
Copy link

ludes2 commented Dec 10, 2024

Any news on this issue?

@ferrarirosso
Copy link

@joelfmrodrigues Assign this issue to me, i will fix it

@joelfmrodrigues joelfmrodrigues added type:bug status:working-on-it Known issue / feature being addressed. Will use other "status:*" labels & comments for more detail. labels Dec 16, 2024
ferrarirosso pushed a commit to ferrarirosso/sp-dev-fx-controls-react that referenced this issue Dec 17, 2024
where the selection of multiple terms is allowed
despite the allowMultipleSelection prop being set to false.
@ferrarirosso
Copy link

@joelfmrodrigues done
I have created two codepens to better analyze the problem :
Example with multiple selections allowed
Example with fix for selectedKey and state

The problem was probably related the undefined value which is handled differently from React

joelfmrodrigues added a commit that referenced this issue Dec 18, 2024
Fixes #1847 - Multiple selections possible when allowMultipleSelection set to false
@joelfmrodrigues joelfmrodrigues added status:fixed-next-drop Issue will be fixed in upcoming release. and removed status:working-on-it Known issue / feature being addressed. Will use other "status:*" labels & comments for more detail. labels Dec 18, 2024
@joelfmrodrigues joelfmrodrigues added this to the 3.21.0 milestone Dec 18, 2024
@joelfmrodrigues
Copy link
Collaborator

joelfmrodrigues commented Dec 18, 2024

Hey @roldengarm, @ludes2, @lucadercoli, the PR from @ferrarirosso to address this issue has just been merged. If you have the chance to test the beta release, please let us know if this issue has been fixed.

@ferrarirosso
Copy link

@joelfmrodrigues tested with 3.21.0-beta.1239409 in our spfx component, works perfectly
btw @ludes2 is in my team, i got the task :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:fixed-next-drop Issue will be fixed in upcoming release. type:bug
Projects
None yet
Development

No branches or pull requests

6 participants