File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
primitives/src/select/components Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -151,6 +151,7 @@ pub fn SelectOption<T: PartialEq + Clone + 'static>(props: SelectOptionProps<T>)
151151 let selected = use_memo ( move || {
152152 ctx. value . read ( ) . as_ref ( ) . and_then ( |v| v. as_ref :: < T > ( ) ) == Some ( & props. value . read ( ) )
153153 } ) ;
154+ let mut did_drag = use_signal ( || false ) ;
154155
155156 use_context_provider ( || SelectOptionContext {
156157 selected : selected. into ( ) ,
@@ -173,11 +174,23 @@ pub fn SelectOption<T: PartialEq + Clone + 'static>(props: SelectOptionProps<T>)
173174 aria_roledescription: props. aria_roledescription. clone( ) ,
174175
175176 onpointerdown: move |event| {
176- if !disabled && event. trigger_button( ) == Some ( MouseButton :: Primary ) {
177+ if !disabled && & event. pointer_type ( ) == "mouse" && event . trigger_button( ) == Some ( MouseButton :: Primary ) {
177178 ctx. set_value. call( Some ( RcPartialEqValue :: new( props. value. cloned( ) ) ) ) ;
178179 ctx. open. set( false ) ;
179180 }
180181 } ,
182+ ontouchstart: move |_| {
183+ did_drag. set( false ) ;
184+ } ,
185+ ontouchend: move |_| {
186+ if !disabled && !did_drag( ) {
187+ ctx. set_value. call( Some ( RcPartialEqValue :: new( props. value. cloned( ) ) ) ) ;
188+ ctx. open. set( false ) ;
189+ }
190+ } ,
191+ ontouchmove: move |_| {
192+ did_drag. set( true ) ;
193+ } ,
181194 onblur: move |_| {
182195 if focused( ) {
183196 ctx. focus_state. blur( ) ;
You can’t perform that action at this time.
0 commit comments