Skip to content

Commit

Permalink
fix: add Array type for radio's label prop & fix all bug I know in ca…
Browse files Browse the repository at this point in the history
…scader
  • Loading branch information
ImJustAMan committed Nov 26, 2020
1 parent f8dd6f5 commit 3d98ed8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
15 changes: 6 additions & 9 deletions packages/cascader-panel/CascaderNode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<el-radio
v-else-if="config.checkStrictly"
:modelValue="checkedValue"
:label="radioLabel"
:label="value"
:disabled="isDisabled"
@change="handleCheckChange"
@click="strictlyEvent"
Expand All @@ -58,7 +58,7 @@
</template>

<script>
import { h, computed, watch, inject, toRefs, Fragment } from 'vue'
import { h, computed, watch, inject, toRefs, Fragment, watchEffect } from 'vue'
import ElCheckbox from '../checkbox'
import ElRadio from '../radio'
import { isEqual } from '../../src/utils/util'
Expand Down Expand Up @@ -99,17 +99,15 @@ export default {
checkedValue
)
const nodeLabel = computed(() => ({
render: panel.renderLabelFn,
node
}))
const disabled = computed(
() => !config.value.checkStrictly && isDisabled.value
)
const radioLabel = computed(() =>
isEqual(value.value, checkedValue.value)
? checkedValue.value
: value.value
)
watchEffect(() => {
if (isEqual(value.value, checkedValue.value))
value.value = checkedValue.value
})
const handleMultiCheckChange = (checked) => {
node.value.doCheck(checked)
Expand Down Expand Up @@ -163,7 +161,6 @@ export default {
// state
// data
nodeLabel,
radioLabel,
disabled,
// useNode
value,
Expand Down
1 change: 1 addition & 0 deletions packages/cascader-panel/CascaderPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ export default {
},
lazyLoad,
getCheckedNodes,
getFlattedNodes,
handleCheckChange,
handleExpand,
renderLabelFn,
Expand Down
16 changes: 10 additions & 6 deletions packages/cascader/Cascader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,10 @@ export default {
},
clearable: Boolean,
filterable: Boolean,
filterMethod: Function,
filterMethod: {
type: Function,
default: undefined
},
separator: {
type: String,
default: ' / '
Expand Down Expand Up @@ -737,16 +740,17 @@ const useSuggestion = ({
const instance = getCurrentInstance()
const suggestions = ref([])
const getSuggestions = () => {
if (!(filterMethod.value instanceof Function)) {
filterMethod.value = (node, keyword) => node.text.includes(keyword)
let internalFilterMethod = filterMethod.value
if (!(internalFilterMethod instanceof Function)) {
internalFilterMethod = (node, keyword) => node.text.includes(keyword)
}
const internalSuggestions = panel
const internalSuggestions = panel.value
.getFlattedNodes(leafOnly.value)
.filter((node) => {
if (node.isDisabled) return false
node.text = node.getText(showAllLevels.value, separator.value) || ''
return filterMethod.value(node, inputState.value)
return internalFilterMethod(node, inputState.value)
})
if (multiple) {
Expand All @@ -769,7 +773,7 @@ const useSuggestion = ({
if (multiple?.value) {
const { checked } = targetNode
targetNode.doCheck(!checked)
panel.calculateMultiCheckedValue()
panel.value.calculateMultiCheckedValue()
} else {
checkedState.value = targetNode.getValueByOption()
toggleDropDownVisible(false)
Expand Down
2 changes: 1 addition & 1 deletion packages/radio/Radio.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default {
props: {
modelValue: [String, Number, Symbol, Boolean, Array],
label: [String, Number, Symbol, Boolean],
label: [String, Number, Symbol, Boolean, Array],
disabled: Boolean,
name: String,
border: Boolean,
Expand Down

0 comments on commit 3d98ed8

Please sign in to comment.