zsoerenm/chips_input

maxChips ignored and documentation needs

Zelfapp opened this issue · 2 comments

Awesome package. Thank you. Trying to understand how to use. Some documentation on the following issues I've run into would be helpful.

As you can see here the suggestion builder is not constrained to the padding on the right side, which exists. How do I style the suggestion builder?

image

Regarding focusNode handling, how do you init the suggestionBuilder from an onTap event on an icon, for example, like you see below?

I've added a focusNode and listener to it, however, tapping out of ChipsInput area or in does nothing. The listener is not registering whether there is focus or not.

ChipsInput(
  maxChips: 3,
  readOnly: true,
  showCursor: false,
  focusNode: _sendToFieldFocusNode,

image

How do you close the suggestionBuilder? I'm tapping around screen, but once it is open it just stays open.

I have maxChips set to 3, but I'm able to add 4+

chips_input.dart: code below seems to contain the logic error for controlling number of chips that can be selected if that is the intent of maxChips.

maxLength: (widget.maxChips != null &&
                      widget.maxChips! <= _chips.length &&
                      _chips.length > 0)
                  ? _chips.length
                  : widget.maxLength,

image

How do I style the suggestion builder?

Currently there is no other possibility to style suggestionbuilder apart from styling the ListTile (see https://github.com/zsoerenm/chips_input/blob/main/lib/chips_input.dart#L700)
If you have an opinion about it, you can make a pull request and change that.
Currently it has an height of 200, an elevation of 4.0 and a padding of 8.

I've added a focusNode and listener to it, however, tapping out of ChipsInput area or in does nothing.

The focus is requested when a user taps onto the chips input (see https://github.com/zsoerenm/chips_input/blob/main/lib/chips_input.dart#L678)
This works for me even if I pass a new focusNode to the chipsInput.

final focusNode = FocusNode()
// ...
ChipsInput(
              focusNode: focusNode,
//...

How do you close the suggestionBuilder?

Good questions. I will have a look into this. For now it is possible to close the suggestionBuilder by clicking the checkmark at the keyboard at the right left bottom.

I have maxChips set to 3, but I'm able to add 4+

I am not able to reproduce this. If there are more than 3 chips in the input, I can't type any character anymore. Could you give a minimal example?

Alright I was able to reproduce the bug with maxChips. This should be fixed in v0.0.5.
I also added an option for the optionsViewBuilder. You can use that instead of the suggestionBuilder for more customization (see Readme).