Skip to content

Commit

Permalink
fix ToSelectElement wrong selection update when no item is present in…
Browse files Browse the repository at this point in the history
… the popup listelement (because of the filtering)
  • Loading branch information
plantec committed Oct 18, 2024
1 parent a066bc0 commit a676507
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 35 deletions.
7 changes: 3 additions & 4 deletions src/Toplo-Examples/ToSandBox.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -1740,7 +1740,7 @@ ToSandBox class >> example_SelectAntDesignIconMonoFiltrable [
withIconProvider: ToAntDesignIconProvider.

select filtrable: true.

select sample: (select popupListElement dataAccessor at: 1).
select dataViewBuilder: [ :dataItemView :iconDesc |
dataItemView addChild:
((iconDesc icon size: 48 asPoint) background: Color veryLightGray).
Expand All @@ -1751,8 +1751,6 @@ ToSandBox class >> example_SelectAntDesignIconMonoFiltrable [
dataItemView childrenDo: [ :child |
child constraintsDo: [ :c | c linear vertical alignCenter ] ] ].

select sample: (select popupListElement dataAccessor at: 1).

select hMatchParent.
select placeholderText:
('Select an icon' asRopedText foreground: Color red).
Expand Down Expand Up @@ -1861,14 +1859,15 @@ ToSandBox class >> example_SelectMonoFiltrable [
yourself)
fontSize: 24;
yourself.
select sample: 'X'.
select popupListElement placeholderBuilder: [ :placeholder :e |
| lab |
placeholder layout alignCenter.
lab := ToAttributedLabel text: phtext.
placeholder addChild: lab ].
select dataViewBuilder: [ :dataItemView :aString |
dataItemView addChild: ((ToLabel text: aString)
fontSize: 28;
fontSize: 18;
yourself) ].
select filtrable: true.

Expand Down
2 changes: 1 addition & 1 deletion src/Toplo-Widget-List/ToInfiniteDataSourceManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ ToInfiniteDataSourceManager >> onItemsSieved: aPositionStart itemCount: anItemCo
"Return true if pending commands should be processed,
otherwise false"

"Register add command"
"Register the sieve command"
finalStepCommands add: (ToInfiniteDataSourceSieveCommand new
positionStart: aPositionStart;
itemCount: anItemCount;
Expand Down
4 changes: 1 addition & 3 deletions src/Toplo-Widget-List/ToListElementEventHandler.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,7 @@ ToListElementEventHandler >> secondaryClickEvent: anEvent [
{ #category : #'list element handling' }
ToListElementEventHandler >> showHidePlaceholderIn: aListElement [

aListElement dataAccessor ifEmpty: [
aListElement selecter deselectAll.
^ aListElement showPlaceholder ].
aListElement dataAccessor ifEmpty: [ ^ aListElement showPlaceholder ].
aListElement hidePlaceholder
]

Expand Down
6 changes: 3 additions & 3 deletions src/Toplo-Widget-Select/ToSelectElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ ToSelectElement >> defaultLayout [
{ #category : #accessing }
ToSelectElement >> filterString [

^ self filterTextField filterString
^ self filterTextField text asString
]

{ #category : #'accessing - selection' }
Expand Down Expand Up @@ -206,13 +206,13 @@ ToSelectElement >> onLayout: aBounds context: aBlElementBoundsUpdateContext [
{ #category : #window }
ToSelectElement >> onPopupWindowClosed [

self filterTextField onPopupWindowClosed
self filterTextField requestFocus
]

{ #category : #window }
ToSelectElement >> onPopupWindowOpened [

self filterTextField onPopupWindowOpened
self filterTextField requestFocus
]

{ #category : #'accessing - selection' }
Expand Down
22 changes: 3 additions & 19 deletions src/Toplo-Widget-Select/ToSelectFilterTextField.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ Class {
#category : #'Toplo-Widget-Select-textInput'
}

{ #category : #accessing }
ToSelectFilterTextField >> filterString [

^ self text asString
]

{ #category : #initialization }
ToSelectFilterTextField >> initialize [

Expand Down Expand Up @@ -78,18 +72,6 @@ ToSelectFilterTextField >> onInstalledIn: aSelectElement [
self infinite addEventHandler: windowPopupHandler
]

{ #category : #window }
ToSelectFilterTextField >> onPopupWindowClosed [

self requestFocus
]

{ #category : #window }
ToSelectFilterTextField >> onPopupWindowOpened [

self requestFocus
]

{ #category : #'api - hooks' }
ToSelectFilterTextField >> onUninstalledIn: aSelectElement [

Expand All @@ -114,5 +96,7 @@ ToSelectFilterTextField >> selectFiltrable: aBoolean [
{ #category : #accessing }
ToSelectFilterTextField >> selectNodeBefore [

^ selectInnerContainer nodes ifEmpty: [] ifNotEmpty: [:nodes | nodes last]
^ selectInnerContainer nodes
ifEmpty: [ ]
ifNotEmpty: [ :nodes | nodes last ]
]
4 changes: 3 additions & 1 deletion src/Toplo-Widget-Select/ToSelectListElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ Class {
{ #category : #'private - commands' }
ToSelectListElement >> applyDataSourceSieveCommand: aDataSourceCommand [
" update the selection according to the sieve selection model"

super applyDataSourceSieveCommand: aDataSourceCommand.
" the window can be opened but invisible if opened from the text input element.
see ToSelectFilterTextField>>onInstalledIn:. #popupWindowHiddenEvent: is sent
to the select popup window manager when the filter is changed "
selectElement currentPopupWindow ifNotNil: [:w | w visibility: BlVisibility visible ]
selectElement currentPopupWindow ifNotNil: [ :w |
w visibility: BlVisibility visible ]
]

{ #category : #accessing }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ ToSingleSelectInnerContainerElement >> dataViewBuilder: aValuable [
" aValuable takes 2 args: the dataItemView and the selected dataItem "

dataViewBuilder := aValuable.
self refreshFromPopupListSelection
self refreshFromPopupListSelection.
fakeDataItem ifNil: [ ^ self ].
self reinstallFakeDataView
]

{ #category : #accessing }
Expand All @@ -48,8 +50,7 @@ ToSingleSelectInnerContainerElement >> defaultLayout [
ToSingleSelectInnerContainerElement >> fakeDataItem: aData [

fakeDataItem := aData.
self uninstallFakeDataView.
self installFakeDataView
self reinstallFakeDataView
]

{ #category : #'t - select inner container' }
Expand All @@ -73,7 +74,6 @@ ToSingleSelectInnerContainerElement >> initialize [
hMatchParent;
constraintsDo: [ :c | c linear vertical alignCenter ].

fakeDataItem := 'X'.
dataViewFactory := selectElement defaultDataViewFactory.
dataViewBuilder := selectElement defaultDataViewBuilder.

Expand Down Expand Up @@ -156,6 +156,14 @@ ToSingleSelectInnerContainerElement >> refreshFromPopupListSelection [
selectElement dispatchEvent: changedEvent
]

{ #category : #initialization }
ToSingleSelectInnerContainerElement >> reinstallFakeDataView [

self uninstallFakeDataView.
self installFakeDataView

]

{ #category : #accessing }
ToSingleSelectInnerContainerElement >> sample: aDataItem [

Expand Down

0 comments on commit a676507

Please sign in to comment.