Skip to content

Commit

Permalink
Merge pull request #318 from qiqingfu/master
Browse files Browse the repository at this point in the history
fix: Radio、Radio-Group、Radio-Button already known bugs
  • Loading branch information
cuixiaorui authored Nov 10, 2020
2 parents 94a3850 + ae29201 commit cfd74c5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
7 changes: 3 additions & 4 deletions packages/radio-button/RadioButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default {
}
function useInject() {
const elForm = inject('elFrom', {})
const elForm = inject('elForm', {})
const elFormItem = inject('elFormItem', {})
return {
elForm,
Expand Down Expand Up @@ -139,11 +139,10 @@ function useModel({ radioGroup }) {
function useStyle({ radioGroup, disabled, value, label, elForm, elFormItem }) {
const { ctx } = getCurrentInstance()
const elFormDisable = (elForm.props || {}).disabled
const elFormItemSize = (elFormItem.ctx || {}).elFormItemSize
const elFormDisable = elForm.disabled
const size = computed(() => {
const temRadioSize = elFormItemSize || (ctx.$ELEMENT || {}).size
const temRadioSize = elFormItem.elFormItemSize || (ctx.$ELEMENT || {}).size
return radioGroup.ctx.radioGroupSize || temRadioSize
})
const isDisabled = computed(() => {
Expand Down
14 changes: 9 additions & 5 deletions packages/radio-group/RadioGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ export default {
setup(props) {
const { modelValue = {}, size = {} } = toRefs(props)
const { dispatch } = useEmitter()
const elFormItem = inject('elFormItem', { ctx: {} })
const { elFormItem } = useInject()
watch(modelValue, (v) => {
dispatch('el.form.change', v)
Expand All @@ -62,6 +61,13 @@ export default {
}
}
function useInject() {
const elFormItem = inject('elFormItem', {})
return {
elFormItem
}
}
function useKeyDown() {
const { ctx } = getCurrentInstance()
onMounted(() => {
Expand Down Expand Up @@ -117,9 +123,7 @@ function useStyle({ elFormItem, size }) {
const { ctx, vnode } = getCurrentInstance()
const radioGroupSize = computed(() => {
return (
size.value || elFormItem.ctx.elFormItemSize || (ctx.$ELEMENT || {}).size
)
return size.value || elFormItem.elFormItemSize || (ctx.$ELEMENT || {}).size
})
const elTag = computed(() => {
Expand Down
7 changes: 3 additions & 4 deletions packages/radio/Radio.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export default {
}
function useInject() {
const elForm = inject('elFrom', {})
const elForm = inject('elForm', {})
const elFormItem = inject('elFormItem', {})
return {
elForm,
Expand Down Expand Up @@ -173,11 +173,10 @@ function useStyle({
elFormItem
}) {
const { ctx } = getCurrentInstance()
const elFormDisable = (elForm.props || {}).disabled
const elFormItemSize = (elFormItem.ctx || {}).elFormItemSize
const elFormDisable = elForm.disabled
const radioSize = computed(() => {
const temRadioSize =
unref(size) || elFormItemSize || (ctx.$ELEMENT || {}).size
unref(size) || elFormItem.elFormItemSize || (ctx.$ELEMENT || {}).size
return isGroup
? radioGroup.ctx.radioGroupSize || temRadioSize
: temRadioSize
Expand Down

0 comments on commit cfd74c5

Please sign in to comment.